html
<view>
<view>
<input type="text" value="{{myText}}" bindinput="bindViewTap"/>
<button bindtap="getUserProfile">add</button>
</view>
<view wx:for="{{list}}" wx:key="index">
//----------传值-----------------------------------------------------------------------------------------------------
<button bindtap="delectItem" data-myid="{{index}}">获取</button>
{{item}}
</view>
</view>
js
// index.js
// 获取应用实例
Page({
data: {
myText:'',
list:[]
},
// 事件处理函数
//---------获取输入框的值---------------------------------
bindViewTap(evt) {
this.setData({
myText:evt.detail.value
})
},
onLoad() {
},
getUserProfile() {
this.setData({
list:[...this.data.list,this.data.myText],
myText:''
})
},
//--------传值-------------------------------------------------------------------------------------------------------------------------
delectItem(evt){
console.log(evt.target.dataset.myid)
},
getUserInfo(e) {
}
})
相关作者
- 获取点赞0
- 文章阅读量264
评论()