-
获取数据javascript
可在 onLoad 生命周期中获取数据,接收一个参数 option 为上个页面传递的参数.
vue -
点击事件tap代替clickjava
二者都会在点击时触发,可是在web手机端,clikc会有300ms延时,因此要用tap代替click做为点击事件,singleTap和doubleTap分别做为单次点击和双击,可是使用tap会带来点击穿透。web
点击穿透和延迟详细:json
http://www.javashuo.com/article/p-uaudxvhh-cd.htmlpost
-
沉浸式头部this
在pages.json中page添加url
"style": { //这里仅支持十六进制 //#ffff0000 为十六进制透明色 "navigationBarBackgroundColor": "#ffff0000" }
背景颜色透明 文字不透明 也可用经过rgba第四个值 alpha值 范围为0.0到1.0之间,0.5为半透明.code
-
自定义返回router
uni.navigateTo({url: ""})
会致使返回页面从新加载.uni.navigateBack({ delta: 1 });
当前页面刷新后没法返回.能够添加事件 以下:
back() { let canBack = true const pages = getCurrentPages() // 有可返回的页面则直接返回,uni.navigateBack默认返回失败以后会自动刷新页面 ,没法继续返回 if (pages.length > 1) { uni.navigateBack(1) return; } // vue router 能够返回uni.navigateBack失败的页面 可是会从新加载 let a = this.$router.go(-1) router.go失败以后则重定向到首页 if (a == undefined) { uni.reLaunch({ url: "/pages/tabbar/index" }) } return; },
-
:style 不支持**`backgroundColor: ${cl}` 语法 改为 :style="{backgroundColor: cl}" 便可
-
头部导航栏差别
可在pages.json中的pages中添加
"style": { // 默认原生导航不显示 "h5": { "titleNView": false }, "enablePullDownRefresh": true // 容许下来刷新 }
添加后:
-
视图容器scroll-view 滚条隐藏
/deep/.uni-scroll-view::-webkit-scrollbar { /* 隐藏滚动条,但依旧具有能够滚动的功能 */ display: none }