| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- // module/health/components/field-ruler/field-ruler.ts
- Component({
- behaviors: ['wx://form-field-group'],
- lifetimes: {
- attached() { }
- },
- properties: {
- title: { type: String, value: '' },
- options: { type: Array, value: [] },
- closeOnOverlayClick: { type: Boolean, value: true },
- },
- /**
- * 组件的初始数据
- */
- data: {
- visible: false,
- selected: [] as (number | undefined)[],
- scrollValue: [] as number[],
- },
- observers: {
- 'options'(options: { value?: number }[]) {
- const selected = options.map(option => option.value)
- this.setData({ selected })
- }
- },
- methods: {
- onShow() {
- this.setData({ visible: true });
- },
- onConfirm() {
- this.setData({
- visible: false,
- selected: [...this.data.scrollValue],
- })
- },
- onCancel() {
- this.setData({ visible: false })
- },
- }
- })
|