You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
810 B
JavaScript
38 lines
810 B
JavaScript
// components/mp-switch/mp-switch.js
|
|
Component({
|
|
properties: {
|
|
trueText: {
|
|
type: String,
|
|
value: '开'
|
|
},
|
|
falseText: {
|
|
type: String,
|
|
value: '关'
|
|
},
|
|
// 传进来的对象
|
|
item: {
|
|
type: Object,
|
|
value: {}
|
|
},
|
|
width: {
|
|
type: Number,
|
|
value: 72
|
|
},
|
|
height: {
|
|
type: Number,
|
|
value: 32
|
|
}
|
|
},
|
|
methods: {
|
|
onChange() {
|
|
console.log(this.data.item);
|
|
this.setData({
|
|
checked: !this.data.item.checked
|
|
}, () => {
|
|
this.triggerEvent('change', {
|
|
value: this.data.item
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}) |