实战经验,满满的干货
1.实现一行左右布局
可以在父级中display:flex; justify-content: space-between;
也可在某一个子级flex-grow: 1; text-align: right;
2.align-items 属性定义flex子项在flex容器的当前行的侧轴(纵轴)方向上的对齐方式
align-self属性是用在单个元素的交叉轴的设置上
3.align-content—针对多行作为一个整体在纵轴上的排列方式,该属性对单行无效
必须对父元素设置属性display:flex,设置排列方式为横向排列flex-direction:row;并且设置换行----
flex-wrap:wrap;这样这个属性的设置才会起作用。
是对父元素进行设置
4.display: inline-block;----可以实现行内布局和块布局,大布局下有好多块,可以设置宽高
5.form组件中的input要有name。input中的type代表弹出的键盘类型
input type=“text” auto-focus name=“name”
在JS中-----var name = e.detail.value.name; //获取姓名输入框内容
6.在success回调函数里是不能直接使用this.setData()的
bindViewTap: function() {
let self = this;
wx.chooseImage({
count: 1,
sizeType: [‘original’, ‘compressed’],
sourceType: [‘album’, ‘camera’],
success(res) {
// tempFilePath可以作为img标签的src属性显示图片,要上传的文件的小程序临时文件路径,每次获取都不一样
const tempFilePaths = res.tempFilePaths----const:用于声明常量, let:声明局部变量
self.setData({userPic: tempFilePaths[0]})
}
})
}
7.网络请求api是wx.request
wx.request({
url: ’ ', //必填,其他的可以不填
data: {
x: ‘’,
y: ‘’
},
header: {
‘content-type’: ‘application/json’ // 默认值
},
success (res) {
console.log(res.data)
}
})
requestTask.abort() // 取消请求任务
8.js中的最后一个函数的末尾不能加逗号,否则会报错。