☄️一个微信小程序页面组件转为Vue组件的库
$ npm install wxmini-to-vue
const path = require('path')
// 导入 wxmini-to-vue
const WTV = require('wxmini-to-vue')
// 实例化
const wtv = new WTV()
// 入口路径
const entryPath = path.resolve(__dirname, './path')
// 存放位置
const outputPath = path.resolve(__dirname, './o/path')
// 执行转换
wtv.transform(entryPath, outputPath)
// 执行完成后会在 [outputPath] 中存放
wtv.transform(entryPath, outputPath)
// 入口路径
const entryPath = path.resolve(__dirname, './path')
// 存放位置
const outputPath = path.resolve(__dirname, './o/path')
// 执行转换
wtv.transform(entryPath, outputPath)
babel code to ast
1. 将wxApi替换成 一些自定义的方式
例如:
wx.showToast => this.$toast
wx.getStorageSync => this.$store2
wx.setStorageSync => this.$store2
2. ..其他处理 暂不细说
使用 htmlparser2 将code 转换成 ast
1. 标签转换
2. 模版转换
使用 csstree 将code 转换成 ast
1. 标签转换
2. 单位转换