简体   繁体   中英

Wechat miniprogram detect slot component changed

I need to know, if it is possible to detect that the content of the slot of a custom component has changed.

This is my component:

//my-component.wxml
<view class = "wrapper">
<! - more code ->
<slot> </slot>
</view>

So to use it I do: <my-component> {{userName}} </my-component>

I need to detect every time value of variable " userName " changes. This is a much simpler example, because if it were the value of a variable it would create a property on the component and create an observer.

I have searched the net a lot and have not found anything about it.

Wechat-miniprogram have no obverse if you want change the data, you can use this.setData({userName:'xxx'}).

Otherwise,if you want to obverse the datachange in view.You can use origin component "input".And bind the "change" event of "input".

The method of development is supported from offical.

If you want to use vue/react to develop your miniprogram, you must select other technology stack or frame likes wepy/taro/uniapp.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM