We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
本次受控改造指南以 Switch 举例。
组件的 propertie 需要增加受控属性对应的 default 值。 如 Switch 的受控值是 value,则对应的 default 值为 defaultValue
Component({ properties: { type: null, value: undefined } })
type = null 是为了保证 defaultValue 没传的时候值为 undefined
不要使用 this.triggerEvent 反而使用 this._trigger
this.triggerEvent
this._trigger
this._trigger('change', { value })
value 对应的是受控属性
Component({ controlledProps: [{ key: 'value', event: 'change' }] })
key 对应的是受控属性,event 则是第二步对应是事件名。
内部不再手动修改对应的属性,只依赖外部传入
如果还有不懂的话,可以联系 @leejim 沟通