32 lines
512 B
JavaScript
32 lines
512 B
JavaScript
// components/Segmented/index.js
|
|
Component({
|
|
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties: {
|
|
list: Array,
|
|
active: Number,
|
|
},
|
|
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
|
|
},
|
|
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
handleChange(e) {
|
|
console.log(e, this.data.active)
|
|
const { index } = e.currentTarget.dataset;
|
|
if (index === this.data.active) {
|
|
return;
|
|
}
|
|
this.triggerEvent("change", { index, name: this.data.list[index] })
|
|
}
|
|
}
|
|
}) |