传送门:官方文档https://mp.weixin.qq.com/debug/wxadoc/dev/framework/app-service/page.html?t=2017112
1.list数据的更改:
定义数组;
array:[{text:'one'},{text:'two'}],{这里相当于有多个数据组,每个数据组的key是text,对应的数值书one,获取数据的时候使用.text;如果改为{message:'one'}},那使用array[0].message.
在微信小程序中更改array的数据,在JavaScript中需要使用过array:array.splice(1,1,'newValue'),方法来更改数据,
但是在微信小程序中可以直接使用:
this.setData({
//array:array.splice(1,1,{text:'text'}),
'array[1].text':'微信的更改list数据方法',
})
来更改数据。
1.2根据数值的数据进行for渲染:
<view wx:for="{{array}}">
{{index}}: {{item.text}}
</view>
2.下拉刷新控件;
首先允许刷新权限
"window":{
"enablePullDownRefresh": "true",
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle":"black"
}
然后直接调用微信封装好的方法:
onPullDownRefresh: function () {
console.log('下拉刷新');
wx.stopPullDownRefresh();
},
3.判断使用在view的显示中
<view wx:if="{{view == 'WEBVIEW'}}"> WEBVIEW </view>
<view wx:elif="{{view == 'APP'}}"> APP </view>
<view wx:else="{{view == 'MINA'}}"> MINA </view>