-
全局引入scss自定义变量文件。我在App.vue里引入报错:Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
Undefined variable: “$masa-font-size-4”.
解决方法:在官方自带的uni.scss文件里import我的scss变量文件。
-
为使得在多端样式统一不变形,我的单位是rpx. rpx与px转换规则:
1 rpx = 750 * ( 1 / 设计稿基准宽度 ) px [也就是如果设计稿基准宽度为750px, 1rpx = 1px] -
HBuilderX 误删代码且不能通过Ctrl + Z 恢复代码,选中文件右键 -> 本地历史记录
-
找到项目根目录下的packages.json文件,加一个tabBar.
注意: pages下面的是path, tabBar下面的是pagePath.
"pages": [{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "xxx"
}
}
],
"tabBar":{
"color": "#cdcdcd",
"selectedColor": "#39cffc",
"borderStyle": "black",
"backgroundColor": "#ffffff",
"list": [
{
"pagePath": "pages/index/index",
"text":"首页",
"iconPath":"static/c1.png",
"selectedIconPath":"static/c1.png"
}
]
},
- uni-app代码在HBuilderX中自动打开时报错:VM91 WAService.js:2 TypeError: Cannot read property ‘forceUpdate’ of undefined
解决办法: 等有微信小程序的APPid的时候微信开发者工具就不会报错了 - 在vue页面修改导航栏标题
monted() {
uni.setNavigationBarTitle({
title: 'xxx'
});
},
在vue页面修改Tab文字
uni.setTabBarItem({
index: 0, //or other number
text: 'xxx'
});
- 不理解的错误:“Property or method “toJSON” is not defined on the instance but referenced during render.”
引起原因:data里声明pages, beforePage, 在onShow里写getCurrentPages()获取当前页
解决方法:不在onShow里写,在我用到的功能函数里写。
xx(){
let pages = getCurrentPage