微信小程序动态添加view
//index.html
<button bindtap='clickMe'> 添加</button>
<input type='input' value='{{value}}' placeholder='请输入' bindblur='getValue'></input>
<view wx:for="{{info}}" wx:key="key">
<view > {{info[index].title}} </view>
</view>
//index.js
data: {
info:[],
value:'',
},
clickMe:function(){
var info = this.data.info;
var title = this.data.title;
var info2 = new Object();
info2.title = title;
info.push(info2);
console.log(info)
this.setData({
info:info
})
},
getValue:function(e){
this.setData({
title:e.detail.value,
})
},