初始化
This commit is contained in:
45
components/wanselect/wanselect.js
Normal file
45
components/wanselect/wanselect.js
Normal file
@@ -0,0 +1,45 @@
|
||||
// pages/components/selector/selector.js
|
||||
Component({
|
||||
/**
|
||||
* 组件的属性列表
|
||||
*/
|
||||
properties: {
|
||||
listData: {
|
||||
type: Array,
|
||||
value: [],
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的初始数据
|
||||
*/
|
||||
data: {
|
||||
selectShow: false,
|
||||
index: 0
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的方法列表
|
||||
*/
|
||||
methods: {
|
||||
// 点击下拉显示框
|
||||
/**
|
||||
* 切换选择框的显示状态
|
||||
* 通过修改selectShow的值来控制选择框的显示/隐藏
|
||||
*/
|
||||
selectTap() {
|
||||
this.setData({
|
||||
selectShow: !this.data.selectShow
|
||||
});
|
||||
},
|
||||
// 点击下拉列表
|
||||
optionTap(e) {
|
||||
let Index = e.currentTarget.dataset.index; //获取点击的下拉列表的下标
|
||||
this.setData({
|
||||
selectShow: !this.data.selectShow,
|
||||
index: Index
|
||||
});
|
||||
this.triggerEvent('optionTap', this.data.listData[Index])
|
||||
},
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user