<progress percent="{{percent1}}" ></progress>
<progress percent="{{percent2}}" activeColor="#DC143C" ></progress>
<view>-----案例------</view>
<view>点击按钮完成,将图片1的进度条更新为80%</view>
<view wx:for="{{imageList}}">
<view>{{item.title}}</view>
<progress percent="{{item.percent}}" ></progress>
</view>
<button bindtap="changePercent" >点击</button>
data: {
percent1:20,
percent2:50,
imageList:[
{id:1,title:"图片1",percent:20},
{ id: 1, title: "图片2", percent: 30 },
{ id: 1, title: "图片3", percent: 60 },
]
},
changePercent:function(){
// 方式1:错误
/*
this.setData({
imageList[0].person: 80
});
*/
// 方式2:可以,由于需要全部修改,所以性能差。
/*
var dataList = this.data.imageList;
dataList[0].percent = 80;
this.setData({
imageList: dataList
});
*/
// 方式3:推荐
var num = 2;
this.setData({
["imageList[0].percent"]:80,
["imageList[" + num + "].percent"]: 90,
["imageList[1].title"]:"突突突突突"
})
},
前端
后端
var dataList = ["alex", "changxin", "cck"]
for (var i in dataList) {
(function(data){
wx.request({
url: 'xxxxx',
success: function (res) {
console.log(data);
}
})
})(dataList[i])
}
刚进入页面,获取前10条。
刷新
全局配置
{
"window": {
"backgroundTextStyle": "dark",
"navigationBarTitleText": "大保健",
"enablePullDownRefresh": false
}
}
局部配置
{
"usingComponents": {},
"enablePullDownRefresh": true
}
停止下拉刷新加载
wx.stopPullDownRefresh();
翻页
3. 简化版:首页
4. 简化版:详细页面
5. 复杂版:首页
6. 复杂版:详细页面