uniapp 学习笔记

170 阅读1分钟
  • 1.swiper image 有默认的高度 用的时候得重置 .swiper{ height: 600rpx;} .tp{height: 600rpx !important; }

  • 2.组件的引用 @/components/banner/banner.vue 按照此格式 直接在页面中引用就可以了

  • 3.子组件不需要scoped

  • 4、同一个页面如果需要页面铺满,H5端需要100vh-navbar(44px)-tabbar(50px)的高度,APP端不需要,则: 样式条件件编译

APP 端如果隐藏了uni的导航栏,则内容会被盖住,需要留一个占位组件,或者直接封装的组件

/* #ifdef APP-PLUS */ 
 page{ height:100vh}
/* #endif */

/* #ifndef H5 */
 page{ height:calc(100vh-94px)}
/* #endif*/
    1. color: #1c64ff; Alt+鼠标左键 可以修改这里的颜色值

6.uniapp中不能使用*选择器

组件只支持嵌套 不支持其他组件或自定义组件,否则会引发不同平台渲染的差异 中支持 \n 换行

7.跳转页面传参(建议参数2个以内)

url:"index/id=" + this.id + "&title=" + this.title
接收  
onload(options){
 console.log( options.id,options.title)
}
**OR**
onload({id,title}){ //解构
 console.log( id,title)
}
参数多的对象或者数组
uni.setStorageSync('userInfo',abc)  //存
uni.getStorageSync('userInfo',abc)  //取
离开时记得移除进入页面前获取的缓存
onUnload(){
  uni.removeStorageSync("userInfo")
}