uni-app小知識點,持續更新。。。

1、使用uni-app自帶的tabBar,當點擊過一次之後就不會刷新的問題:
    將onLoad裏的方法全部移到onShow裏面去
2、去掉頂部導航欄

1、"navigationStyle": "custom"

2、"app-plus": {
                    "titleNView": false,
                    "bounce": "none"
                }          (會導致APP的導航欄也祈禱)

3、寬度使用upx,不能進行計算,所以寬度不會根據改變而改變

4、uni-app的頂部導航欄,返回重置數據使用  onBackPress  

5、在view圖文列表中,使用@tap沒有反應,可改爲@click

6、uni-app打包生成H5,可用document.title = '',設置應用的名稱

7、有些地方的樣式寬度設置一個最小寬度,避免出現縮放的問題

8、uni-app打包H5在弱網的情況下出現了“網絡不給力,點擊重試”的問題:

  在manifest.json中設置sync,詳見:https://uniapp.dcloud.io/collocation/manifest?id=h5-async

9、文本框觸發回車事件

<input type="text" confirm-type="search" @confirm="search()" />

10、APP鎖定屏幕方向

//#ifdef APP-PLUS
            plus.screen.lockOrientation('portrait-primary'); //鎖定屏幕方向 
            //#endif

11、修改switch的背景顏色和大小

<switch name="switch" @change="couponChange" checked color="#ff4964" style="transform:scale(0.7)" />

12、uni-app添加遮罩層mask,遮罩下的頁面可以滾動,添加

document.body.style.position = 'fixed';

當去掉遮罩時,將body改爲static

document.body.style.position = 'static';

13、正式適配去掉一些字符

name.replace(/[&\;\\\"、,。_包郵免費折扣!\-]/g,'')

14、移動端H5調起系統的複製功能的CSS寫法

-webkit-touch-callout: all;
-webkit-user-select: all;
-moz-user-select: all;
-ms-user-select: all;
user-select: all;

15、定位到某個位置

document.getElementById("id").scrollIntoView();

16、當出現蒙版時,將body裏的內容固定
document.body.style.position = 'static';  

document.body.style.position = 'fixed';

17、蒙版
 

            position: fixed;
            top: 0;
            left: 0;
            z-index: 999;
            width: 100%;
            height: 100vh;
            background: rgba(0, 0, 0, 0.4);
            z-index: 6000;

18、獲取滾動條位置

onPageScroll: function(Object) {
    console.log(Object.scrollTop)			
},

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章