一、使用less module不生效的问题
1、在config/index.js文件将cssModules的enable属性置为true
cssModules: {
enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
config: {
namingPattern: 'module', // 转换模式,取值为 global/module
generateScopedName: '[name]__[local]___[hash:base64:5]'
}
}
2、将styles.less文件的文件名改为styles.module.less (如果使用global模式那么就可以不修改文件名)
二、用vscode开发个别标签无法自动补全
1、在首选项-用户片段-typescriptreact.json中配置
"Print to console": {
"prefix": "text",
"body": [
"<text>$1</text>",
],
"description": "text标签"
}
三、想用taro-ui,但是项目里使用的是less
1、安装sass解析器
yarn add @tarojs/plugin-sass
2、如果使用的是taro 3.x版本,则安装taro-ui时也需要安装3.x版本
yarn add taro-ui@3.0.0-alpha.10
3、在app.ts中加入,这种是全量引入,可以在这里按需引入
import 'taro-ui/dist/style/index.scss'
四、html标签不生效
可能是由于taro版本和plugin-html版本不一致导致
注意注意注意:要先装plugin-sass,再安装plugin-html,否则装不上
五、怎么设置启动页
方法1、默认app.config.ts中的pages属性的第一个为启动页
方法2、app.config.ts中设置entryPagePath属性
方法3、微信开发者工具中添加编译模式,设置启动页
六、不是合法域名
微信开发者工具-详情-本地设置-不校验合法域名
七、调用chooseLocation失效
可能的原因:在app.config.ts中未配置:
permission: {
"scope.userLocation": {
desc: "你的位置信息将用于小程序位置接口调用"
}
},
八、父传子会报错不存在属性
子组件不要声明为FC类型
九、scrollview的scrolltop属性无效
设置scrolltop的值必须改变,比如设为-1然后再设为0则有效
十、使用echarts
https://blog.csdn.net/haiditao/article/details/120417193
做可移动的图表时报错,t.preventDefault is not a function
删除t.preventDefault
Cannot read property ‘refresh’ of null
示例代码中ref使用的是回调形式,而我自己的代码使用的是函数式组件,应该改用useRef,至此在taro中使用echarts的问题基本全部解决。
修改了源码怎么搞?