双向绑定

简易双向绑定

1⃣️当需要在用户输入的同时改变this.data.myvalue,需要借助简易双向绑定机制,可以在对应项目之前加入model:前缀

2⃣️这样,当输入框的值被改变了,this.data.myvalue也会同时改变。

//mycomponent.wxml

<label>用户名:</label>
<input type="text" model:value="{{myvalue}}" bindblur="getvalue"></input>
//mycomponent.js data: { myvalue:"" }, methods: { getvalue:function(event){ console.log(event.detail.value); } }

https://developers.weixin.qq.com/miniprogram/dev/framework/view/two-way-bindings.html

 

 

posted @ 2021-12-30 14:11  shanlu  阅读(58)  评论(0)    收藏  举报