UNPKG

wx-mini-weview

Version:

weixin UI

115 lines (106 loc) 2.57 kB
const { WvInheritable } = require('../../behaviors/WvInheritable'); const { WvComponentEvent } = require('../../behaviors/WvComponentEvent'); Component({ options: { styleIsolation: 'apply-shared', addGlobalClass: true, virtualHost: true }, externalClasses: ['ext-class'], behaviors: [ WvInheritable({ properties: { // Remove name property and add index property index: { type: Number, value: -1 }, value: { type: null, value: null }, theme: { type: String, value: '' }, selectedTheme: { type: String, value: '' }, disabled: { type: Boolean, value: false }, border: { type: Boolean, value: false }, size: { type: String, value: '' }, shape: { type: String, value: '' }, selected: { type: Boolean, value: false }, selectionType: { type: String, value: 'checkmark' }, checkmark: { type: Boolean, value: false }, checkmarkPosition: { type: String, value: 'top-right' }, dimension: { type: Boolean, value: false } }, childrenProperties: {} }) ], relations: { '../tagselector/tagselector': { type: 'parent', linked(target) { this.linkParentNode('tagselector', target); }, unlinked() { this.unlinkParentNode('tagselector'); } } }, lifetimes: { attached() { if (this.data.wvInheritableApply.value === null || this.data.wvInheritableApply.value === undefined) { this.setInheritedProps({ value: this.data.wvInheritableApply.index }); } } }, methods: { onTap() { if (this.data.wvInheritableApply.disabled) return; // 通知父组件 - 使用toggle方法 const parentSelector = this.getParentNode('tagselector'); if (parentSelector) { parentSelector.toggle(this.data.wvInheritableApply.index); } // 使用不同名称的事件,避免与原生tap重名 this.triggerEvent('tagtap', { value: this.data.wvInheritableApply.value, index: this.data.wvInheritableApply.index, selected: this.data.wvInheritableApply.selected }); } } });