node版本切到14
全局安装taro-cli, 参考taro快速开始
创建项目时候选择webpack4
uni.api 修改为Taro.api
注意uni的api使用时不需要引入uni, Taro需要导入import Taro from '@tarojs/taro'
uni.getStorage()
// =>
import Taro from '@tarojs/taro'
Taro.getStorage()
- Taro 不支持style标签的scoped, 改成CSS Modules
- 在配置中开启CSS Modules, 参考taro
<style lang="scss" scoped>
// =>
<style lang="scss" module>
class="main"
// =>
:class="$style['main']"
// 搜索框快速替换正则
class="([^"]+)"
:class="$style['$1']"
// 多类名或者原本有:class属性的需要再修改
:class="{
[$style['class1']]: true,
[$style['class2']]: true
}"
image.png
- taro不支持部分html标签, 需要转成v-html写法, 通过addEventListener添加事件