// components/myButton/myButton.js Component({ options: { styleIsolation: 'apply-shared' }, behaviors: ['wx://form-field-button'], /** * 组件的属性列表 */ properties: { type: String, size: String }, lifetimes: { attached: function () { if (this.data.type !== 'default' && this.data.type !== 'primary') { this.setData({ type: 'default' }) } if (this.data.size !== 'default' && this.data.type !== 'large') { this.setData({ size: 'default' }) } } }, /** * 组件的初始数据 */ data: { }, /** * 组件的方法列表 */ methods: { handleTap: function () { this.triggerEvent('tap'); } } })