1.返回上级页面
wx.navigateBack({
// delta表示的是返回的层级,1表示上一层
delta: 1
});
2.点击后将数据从xml中传递到js中。这里的data-id就是自定义的属性
wxml中
<view class='tab-item {{id==item.id?"tab-item-active":""}}' wx:for="{{navList}}" bindtap='changeTab' wx:key="{{item.id}}" data-id="{{item.id}}" >
{{item.name}}
<!-- <text class='tab-txt'>{{item.name}}</text> -->
</view>
在js中,就能通过e.currentTarget.dataset.id进行获取,
changeTab(e) {
console.log(e)
if (this.data.id == e.currentTarget.dataset.id) {
return false;
}
this.setData({
id: e.currentTarget.dataset.id
})
this.getDetail();
},
3.将数据传递到上级页面
https://blog.csdn.net/weixin_41625322/article/details/82587779
4.微信小程序中的 hover-class 设置点击效果
https://www.cnblogs.com/yaoyuqian/p/8232890.html
5.使用z-index进行配置显示的层级
但是只有和position配合的时候才能生效。
6.小程序的生命周期
其中第一次初始化时顺序 onLoad onShow onReady
如果跳转到其他页面 onHide
回到当前页面 onShow
onLoad: function (options) {
// 页面初始化 options为页面跳转所带来的参数
console.log("=========onLoad")
},
onReady: function () {
// 页面渲染完成
console.log("=========onReady")
},
onShow: function () {
console.log("=========show")
// 页面显示
this.getCartList();
},
onHide: function () {
// 页面隐藏
console.log("=========onHide")
},
onUnload: function () {
// 页面关闭
console.log("=========onUnload")
},