1.小程序赋值
that.setData({
weekList: weekList,
["cWeekRange.startTime"]: preStart,//对象里的某个参数赋值
["dataList["+index+"].qty2"]:ss2.replace(/,/g, ""),//数组里某个对象的参数
cSelected: cSelected
});
2.小程序方法
<view bindtap='changeDate'></view>
changeDate: function(e) {}
3.是否有某个class
<view class='day {{item.mdate==currentDate?"day-current":""}}'>{{item.date}}</view>
4.小程序提示
wx.showToast({
title: ret.data.message,
icon: "none",
emptyShow:true
})
5.小程序input双向绑定:html到js响应
多个input框情况
html
<view class='mgroup'>
<view class="line"></view>
<view class="item">
<label class="des">消毒区域</label>
<input class="val" value="{{model.area}}" bindinput="inputChange" data-name='area'></input>
</view>
<view class="line"></view>
<view class="item">
<label class="des">消毒物品</label>
<input class="val" value="{{model.goods}}" bindinput="inputChange" data-name='goods'></input>
</view>
<view class="line"></view>
<view class="item">
<label class="des">记录人</label>
<input class="val" value="{{model.userName}}" bindinput="inputChange" data-name='username'></input>
</view>
</view>
js
data: {
model:{
area:'',
goods:'',
remark:'',
userName:''
},
},
//
inputChange:function(e){
let that = this;
var name = e.currentTarget.dataset["name"];//获取input的name
var property = "";
switch (name) {
case "area":
property = "model.area";
break;
case "goods":
property = "model.goods";
break;
case "username":
property = "model.userName";
break;
case "remark":
property = "model.remark";
break;
}
that.setData({
[property]: e.detail.value //赋值
});
},
6.小程序session存取值
//存
//rinfo名称,model值
wx.setStorageSync("rinfo", model);
//取
onLoad: function(options) {
var rinfo = wx.getStorageSync("rinfo");
this.setData({
rinfo: rinfo
})
},