本文為一些雜項的聚合;
首先wxml代碼:
<view class="myToast" hidden="{{nullHouse}}">暫無有關(guān)信息</view><view bindtap="clickArea">點(diǎn)擊此處</view> 注:hidden屬性用于切換比較頻繁的地方。wxss代碼設(shè)置彈窗樣式:
.myToast{width:240rpx;height:130rpx;line-height: 130rpx;margin:80rpx 35%;border-radius:20rpx;background-color: rgb(114,113,113);color:rgb(255,255,255);font-size: 36rpx;text-align: center;position: absolute;z-index: 100;opacity: 0.85;}js:
Page({data:{nullHouse:true, //先設(shè)置隱藏},onLoad:function(options){// 頁面初始化 options為頁面跳轉(zhuǎn)所帶來的參數(shù)},onReady:function(){// 頁面渲染完成},onShow:function(){// 頁面顯示},onHide:function(){// 頁面隱藏},onUnload:function(){// 頁面關(guān)閉},clickArea:function(){var that = this;this.setData({nullHouse:false, //彈窗顯示}) setTimeout(function(){that.data.nullHouse = true, //1秒之后彈窗隱藏},1000)},})注:setTimeout()函數(shù)是異步的,當(dāng)計算機(jī)執(zhí)行到setTimeout時,此任務(wù)先暫停并保存,繼續(xù)執(zhí)行后續(xù)未完成的任務(wù),當(dāng)條件滿足時,再將setTimeout的執(zhí)行任務(wù)放回任務(wù)隊列的后面,等待執(zhí)行。
1、js里面如何獲取data里面定義的值:this.data.參數(shù)名,例如在data里面定義了一個num = 1,我要得到一個num,應(yīng)該這樣寫this.data.num;
2、將內(nèi)容存為全局的:在app.js,里面定義一個變量a,在存的頁面 getApp().globalData.a = 你要存的信息;
3、取全局變量:也是一樣的getApp().globalData.a
4、如果是渲染層報錯:可能原因是:xml頁面里面調(diào)用了方法,或者{{}}沒有配對。
5、跳轉(zhuǎn)頁面代碼:
① wx.navigateTo({url:"跳轉(zhuǎn)的路徑"}); 例如:wx.navigateTo({url:"../shopcar/shopcar"});這個自帶返回上一頁的功能,但是只能最多打開五個頁面。 ②wx.redirectTo({url:"跳轉(zhuǎn)的路徑"});會關(guān)閉當(dāng)前頁面再跳轉(zhuǎn)到另外一個頁面
6、返回上一個頁面:wx.navigateBack({delta: 1});delta:后面接返回的頁面層數(shù)
// 1px border@mixin px-border($color,$border:all) {position: relative;&:after {content: " ";position: absolute;top: 0;left: 0;@if $border == all {border: 1px solid $color;}@else {@each $member in $border{border-#{$member}: 1px solid $color;};}width: 200%;height: 200%;-webkit-transform: scale(0.5);transform: scale(0.5);@media (-webkit-min-device-pixel-ratio:2.5) {width: 300%;height: 300%;-webkit-transform: scale(.33333);transform: scale(.33333);}-webkit-transform-origin: 0 0;transform-origin: 0 0;box-sizing: border-box;}}