2025-06-06 15:17:30 +08:00

46 lines
908 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Component({
options: {
// 允许外部样式影响组件
styleIsolation: 'apply-shared'
},
properties: {
name: {
type: String,
value: '',
required: true
},
size: {
type: String,
value: ''
},
index: {
type: Number,
value: 0
},
extClass: {
type: String,
value: ''
}
},
observers: {
// 自动补全单位数字默认加rpx
'size': function(val) {
if (!val) return
this.setData({
formattedSize: /\d$/.test(val) ? `${val}rpx` : val
})
}
},
data: {
formattedSize: ''
},
methods: {
handleClick() {
this.triggerEvent('click', { index: this.properties.index })
}
}
})