1. < text/> 组件内只支持 <text/> 嵌套。不支持嵌套image组件,不然图片显示不出来
2. setData()回调传递的问题
3. scroll-view 点击相应盒子,以动画的形式移动到索引的位置
添加属性 scroll-into-view=“{{ toIndex }}”
给每个盒子动态分配ID,索引的位置toIndex就是索引的id值。
添加动画:添加属性scroll-with-animation=“true”,盒子就变速移动到索引的位置
https://blog.csdn.net/zhaoyazhi2129/article/details/53787695
4. 阻止微信小程序按钮自动功能例如“客服”、"分享"点击之后的冒泡
if (e.target.id.indexOf('share-btn') > -1) return
5. 动态添加类
class = "gooddesc-special {{ gooddescShow ? 'bbe0' : 'gooddesc-special' }} "
6. 动态选择多个盒子中的一个
<view wx:for="{{ productFamily }}"
wx:key="index"
data-index="{{ index }}"
class="family-size {{ clickId == index ? 'click-family-size' : 'noclick-family-size'}}"
catchtap="clickProductSize">
{{ item }}
</view>
12. 动态选择多个盒子中的一个 再次点击 取消选择
let clickAgain = that.data.clickAgain
let index= e.currentTarget.dataset.index
if (clickAgain == index){
if (that.data.clickId == -1){
that.setData({
clickId: index
});
}else{
that.setData({
clickId: -1
});
}
}else{
that.setData({
clickAgain: index,
clickId: index
});
}
13. 微信小程序模板的引用
模板文件:
<template name="msgItem">…………</template>
引用的方式:
<import src ="../template/template.wxml"/>
<template is="msgItem" data="{{...cancelbeans}}" />
@import '../template/template.wxss';
7. 小程序 js 库。国密算法 sm2、sm3 和 sm4 的实现 sm-crypto