一.布局
1.整个屏幕(高度、宽度100%),内容水平和竖直都居中
position: fixed;
height: 100%;width: 100%;
display:flex;flex-direction:column;
align-items:center;/*垂直居中*/
justify-content: center;/*水平居中*/
2.输入框
placeholder="请输入xxx" placeholder-class="placeholder"
二.小程序
1.for循环
<block wx:for="{{answer}}" wx:item="item" wx:key="key"></blcok>
2.给数组加成员
data:{
? ? answer:["1","2"]
}
let answer = this.data.answer;
answer.push("1");
console.log(answer)
this.setData({
????answer: answer
})
3.给对象增加元素
let answer = this.data.answer;
var obj = new Object();
obj.content='111';
obj.score="30";
console.log(obj)
answer.push(obj);
console.log(answer)? ? ? ?
this.setData({
? ? answer: answer
})
4.传参数
data-ppid="{{pro.pid}}"
//获取
var pid1=event.currentTarget.dataset.ppid;
wx.navigateTo({
????url: '/pages/pro/pro?pid='+ pid1,
});
5.获取输入框的值
<form bindsubmit="formSubmit">
? ? ? ? <input focus="{{true}}" name="inp"></input>
? ? ? ? <button formType="submit"?>发送</button>
</form>
formSubmit: function (e) {
? ?var inp=e.detail.value.inp
}
6.获取数组长度
wxml中直接
{{array.length}}
js中
array.length
7.强制转换
let i = parseInt(count);
console.log(i)
8.字符串转数组
var list=JSON.parse(res.data)
9.数组里插入一个属性
for (var i = 0; i < list.length; i++) {
list[i].sex = '男';
}