Skip to content

Instantly share code, notes, and snippets.

@lolisTop
Created April 12, 2020 09:08
Show Gist options
  • Save lolisTop/47191f7e55373b3be0bee01848afc249 to your computer and use it in GitHub Desktop.
Save lolisTop/47191f7e55373b3be0bee01848afc249 to your computer and use it in GitHub Desktop.
wechat bind
// pages/about/about.js
Page({
/**
* 页面的初始数据
*/
data: {
inputList: []
},
onLoad() {
let inputList = [];
for (let index = 0; index < 2; index++) {
inputList.push({ text: index });
}
this.setData({
inputList
});
},
input(el) {
let inputList = this.data.inputList;
inputList[el.currentTarget.dataset.index].text = el.detail.value;
this.setData({
inputList
});
}
});
<view class="view" wx:for="{{inputList}}" wx:key="index">
<input bindinput="input" value="{{item.text}}" data-index="{{index}}" placeholder="输入信息" />
</view>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment