zhangdaren
zhangdaren
  • 发布:2019-06-20 15:23
  • 更新:2024-03-29 21:03
  • 阅读:77585

miniprogram-to-uniapp使用指南(各种小程序项目转换为uni-app项目)

分类:uni-app

工具现在支持npm全局库、HBuilderX插件两种方式使用,任君选择,HBuilderX插件地址:https://ext.dcloud.net.cn/plugin?id=2656

一、它是谁?

【miniprogram-to-uniapp】转换微信小程序”项目为uni-app项目(新版本工具已经支持各种小程序转换)。

二、它的原理是什么?

最初是学了半节课堆和栈,觉得词法分析挺有意思的,再加上转换小程序插件时,发现这些繁琐的操作完全可以使用程序来完成。
核心是使用Babel获取AST(词法分析),然后或使用Babel自带函数增删,或正则分析替换等等操作。
可能有的朋友觉得,这种为啥不是纯正则分析? 纯正则可以解决一部分问题,对于标签与标签内容,其实正则是很难进行区分的哈。

三、它能做哪些事情?

  • 支持微信、QQ、头条/抖音、支付宝/钉钉和百度等小程序转换到 uni-app 项目
  • 支持有/无云开发的小程序项目转换为 uni-app 项目(cloudfunctions 目录将被忽略,uni-app 结合小程序云开发见:使用 uni-app 进行微信小程序云开发经验分享)
  • 支持解析 TypeScript 小程序项目
  • 支持解析使用 npm 模块的小程序项目
  • 支持解析 include 标签
  • 支持解析 template 标签
  • 支持解析 Behavior 文件为 mixins 文件
  • 支持.js', .wxml 和*.wxss 文件进行相应转换,并做了大量的优化
  • 支持识别 App、Page、Component、VantComponent、Behavior 和纯 Javascript 文件的转换
  • 修复变量名与函数重名的情况
  • 合并使用 require 导入的 wxs 文件
  • setData() polyfill
  • 搜索未在 data 声明,而直接在 setData()里使用的变量,并修复
  • 使用jyf-parser替换 wxParse(感谢网友 “爱瑞巴勒康忙北鼻” 的建议)
  • 因 uni-app 会将所有非 static 目录的资源文件删除,因此将所有资源文件移入 static 目录,并修复所有能修复到的路径(目前 uni 编译时会将非 static 目录的文件复制一份到 static 目录,但并不完全,因此本功能仍保留)

四、它还有哪些不支持转换?

  • 不支持转换反编译后的小程序项目
  • 不支持转换使用 uni-app 编译的小程序项目
  • 不支持转换使用 redux 开发的小程序(代表为:网易云信小程序 DEMO)
  • 不支持转换使用 wxpage 开发的小程序(https://github.com/tvfe/wxpage)
  • 不支持转换使用腾讯 omi 开发的小程序(https://github.com/Tencent/omi)
  • 不支持转换小程序抽象节点 componentGenerics
  • 不支持 component 里的 pageLifetimes 生命周期,请手动绕过
  • 不支持使用 js 系统关键字作为函数或变量名(如 default、import、return、switch 等)
  • 不支持以\$开头的变量名称,如 Page({data:{$data:{name:"hello"}}}) ,刚好\$data 是 vue 内置变量,so 不支持,需手动修复
  • 不支持以动态绑定的函数<input @input="test{{index+1}}">,需手动修复
  • 更多,请参照miniprogram to uniapp 工具答疑

五、怎么使用?

第一步

在命令行里,运行【 npm install miniprogram-to-uniapp -g 】进行安装,因为这个包是工具,要求全局都能使用,所以需要-g进行全局安装。
如果运行npm报错,请先安装Node.js,下载地址:https://nodejs.org/zh-cn/

第二步

继续在命令行里,运行【 wtu -V 】,执行结果如下:

显示版本号,说明已经安装成功了。(wtu -> 取自wx to uni之意,后面都用这个全局命令)

第三步

在命令行里,输入【wtu -i "你的小程序项目路径"】
注意 -i 前面和后面都有空格!!!
注意 -i 前面和后面都有空格!!!
注意 -i 前面和后面都有空格!!!
如:【wtu -i "E:\zpWork\Project_self\miniprogram-to-uniapp\test\test-wx-to-uni"】 ,回车后即可以在源项目同及目录得到一个后缀为_uni的目录,即转换成功。

转换前:

转换后:

转换后的项目文件对比(左边是小程序项目,右边是Uni-app项目目录):

第四步

将转换后的xxx_uni项目导入到hbuilder X,
点击菜单 运行--> 运行到小程序模拟器-->微信开发者工具!(如果是使用了vant的项目,请运行到H5,vant项目转换后仅支持H5和app)
点击菜单 运行--> 运行到小程序模拟器-->微信开发者工具!(如果是使用了vant的项目,请运行到H5,vant项目转换后仅支持H5和app)
点击菜单 运行--> 运行到小程序模拟器-->微信开发者工具!(如果是使用了vant的项目,请运行到H5,vant项目转换后仅支持H5和app)
重要的话说三遍!
然后查看转换后的项目运行到小程序,是否可以正常运行无报错!
(因为这种转换非100%,所以至少需要保证 小程序-->uniapp-->小程序仍然能正常运行,再考虑运行到其他小程序或app),
如有报错,请根据miniprogram to uniapp 工具答疑 进行修改,保证无报错,然后再运行到其他平台。

工具升级

因为工具更新比较频繁,安装后,可以使用如下命令进行升级:
npm update miniprogram-to-uniapp -g

注意:

  1. 遇到问题请参考文档:miniprogram to uniapp 工具答疑
  2. github上面的只是源代码。 日常使用,"仅"需要运行【 npm install miniprogram-to-uniapp -g 】进行安装才行,无需下载工具源码。
  3. 每次转换时都会将输出目录清空,请注意代码保存。
  4. 后续会有版本更新,请及时关注并更新~~,可以关注QQ群:780359397 获取最新信息

对于使用有疑问或建议,可以加入QQ群:780359397 进行讨论。

<a target="_blank" href="http://shang.qq.com/wpa/qunwpa?idkey=6cccd111e447ed70ee0c17672a452bf71e7e62cfa6b427bbd746df2d32297b64"><img border="0" src="http://pub.idqqimg.com/wpa/images/group.png" alt="小程序转uni-app讨论群" title="小程序转uni-app讨论群"></a>

因为有朋友使用本工具导致自己文件被删,在此表示抱歉!

this.setData()代码出处:https://ask.dcloud.net.cn/article/35020,在些表示感谢~

转换工具源码:https://github.com/zhangdaren/miniprogram-to-uniapp ,欢迎star和建议~

如有遇到bug或问题,欢迎评论、给出改进建议,感谢~~

21 关注 分享
z***@qq.com m***@gmail.com 7***@qq.com orageBeardApe 邓琪昌 bzliukai 我要 撇横横 8***@qq.com g***@126.com DigitalYu jinjidecj ai666 9***@qq.com heck b***@126.com 2***@qq.com Dlog_帅 灯下等雪 aliang888 876

要回复文章请先登录注册

stackxin

stackxin

小程序原生,转坏失败
现象:转换后pages目录下文件夹均为空
错误内容:
template里的data属性 ==> "{{...item, index}}" 需要替换的属性 ==> {}
template里的data属性 ==> "{{...item, index}}" 需要替换的属性 ==> {}
(node:16268) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token, expected "," (38:1)
at Parser.raise (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:7013:17)
at Parser.unexpected (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:8384:16)
at Parser.expect (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:8370:28)
at Parser.parseObj (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9954:14)
at Parser.parseExprAtom (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9582:28)
at Parser.parseExprSubscripts (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9219:23)
at Parser.parseMaybeUnary (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9199:21)
at Parser.parseExprOps (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9067:23)
at Parser.parseMaybeConditional (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9040:23)
at Parser.parseMaybeAssign (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9000:21)
(node:16268) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:16268) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:16268) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token, expected "," (38:1)
at Parser.raise (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:7013:17)
at Parser.unexpected (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:8384:16)
at Parser.expect (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:8370:28)
at Parser.parseObj (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9954:14)
at Parser.parseExprAtom (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9582:28)
at Parser.parseExprSubscripts (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9219:23)
at Parser.parseMaybeUnary (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9199:21)
at Parser.parseExprOps (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9067:23)
at Parser.parseMaybeConditional (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9040:23)
at Parser.parseMaybeAssign (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9000:21)
(node:16268) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 5)
(node:16268) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token, expected "," (38:1)
at Parser.raise (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:7013:17)
at Parser.unexpected (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:8384:16)
at Parser.expect (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:8370:28)
at Parser.parseObj (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9954:14)
at Parser.parseExprAtom (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9582:28)
at Parser.parseExprSubscripts (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9219:23)
at Parser.parseMaybeUnary (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9199:21)
at Parser.parseExprOps (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9067:23)
at Parser.parseMaybeConditional (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9040:23)
at Parser.parseMaybeAssign (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9000:21)
(node:16268) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 7)
(node:16268) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token, expected "," (38:1)
at Parser.raise (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:7013:17)
at Parser.unexpected (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:8384:16)
at Parser.expect (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:8370:28)
at Parser.parseObj (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9954:14)
at Parser.parseExprAtom (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9582:28)
at Parser.parseExprSubscripts (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9219:23)
at Parser.parseMaybeUnary (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9199:21)
at Parser.parseExprOps (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9067:23)
at Parser.parseMaybeConditional (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9040:23)
at Parser.parseMaybeAssign (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9000:21)
(node:16268) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 8)
(node:16268) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token, expected "," (38:1)
at Parser.raise (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:7013:17)
at Parser.unexpected (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:8384:16)
at Parser.expect (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:8370:28)
at Parser.parseObj (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9954:14)
at Parser.parseExprAtom (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9582:28)
at Parser.parseExprSubscripts (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9219:23)
at Parser.parseMaybeUnary (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9199:21)
at Parser.parseExprOps (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9067:23)
at Parser.parseMaybeConditional (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9040:23)
at Parser.parseMaybeAssign (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9000:21)
(node:16268) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 11)
(node:16268) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token, expected "," (38:1)
at Parser.raise (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:7013:17)
at Parser.unexpected (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:8384:16)
at Parser.expect (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:8370:28)
at Parser.parseObj (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9954:14)
at Parser.parseExprAtom (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9582:28)
at Parser.parseExprSubscripts (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9219:23)
at Parser.parseMaybeUnary (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9199:21)
at Parser.parseExprOps (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9067:23)
at Parser.parseMaybeConditional (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9040:23)
at Parser.parseMaybeAssign (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9000:21)
(node:16268) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 12)
(node:16268) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token, expected "," (38:1)
at Parser.raise (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:7013:17)
at Parser.unexpected (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:8384:16)
at Parser.expect (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:8370:28)
at Parser.parseObj (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9954:14)
at Parser.parseExprAtom (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9582:28)
at Parser.parseExprSubscripts (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9219:23)
at Parser.parseMaybeUnary (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9199:21)
at Parser.parseExprOps (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9067:23)
at Parser.parseMaybeConditional (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9040:23)
at Parser.parseMaybeAssign (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9000:21)
(node:16268) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 14)
(node:16268) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token, expected "," (38:1)
at Parser.raise (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:7013:17)
at Parser.unexpected (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:8384:16)
at Parser.expect (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:8370:28)
at Parser.parseObj (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9954:14)
at Parser.parseExprAtom (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9582:28)
at Parser.parseExprSubscripts (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9219:23)
at Parser.parseMaybeUnary (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9199:21)
at Parser.parseExprOps (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9067:23)
at Parser.parseMaybeConditional (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9040:23)
at Parser.parseMaybeAssign (C:\Users\Administrator\AppData\Roaming\nvm\v10.16.2\node_modules\miniprogram-to-uniapp\node_modules\@babel\parser\lib\index.js:9000:21)
(node:16268) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 16)
Convert app.css success!
2020-01-13 16:06
wwzjjk

wwzjjk

小程序 用了 vant-ui,转换出错,不能运行,大佬又解决方案吗?
Module Error (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/loaders/templateLoader.js):
09:37:50.494 (Emitted value instead of an instance of Error)
09:37:50.502 Errors compiling template:
09:37:50.502 Cannot use <slot> as component root element because it may contain multiple nodes.
09:37:50.509 1 |
09:37:50.509 2 | <slot></slot>
09:37:50.516 | ^^^^^^^^^^^^^
09:37:50.517 3 |
09:37:50.525 at C:\Users\wz\Desktop\mini_unijs\wx-smzdx_uni\lib\vant\radio-group\index.vue:0
09:37:50.526 Module build failed (from ./node_modules/babel-loader/lib/index.js):
09:37:50.534 语法错误: C:\Users\wz\Desktop\mini_unijs\wx-smzdx_uni\lib\vant\mixins\transition.js: Unexpected token, expected "}" (4:7)
09:37:50.537 2 | import { isObj } from '../common/utils';
09:37:50.547 3 | const getClassNames = name => ({
09:37:50.547 > 4 | enter: `van-${name}-enter van-${name}-enter-active enter-class enter-active-class`,
09:37:50.556 | ^
09:37:50.556 5 | 'enter-to': `van-${name}-enter-to van-${name}-enter-active enter-to-class enter-active-class`,
09:37:50.563 6 | leave: `van-${name}-leave van-${name}-leave-active leave-class leave-active-class`,
09:37:50.564 7 | 'leave-to': `van-${name}-leave-to van-${name}-leave-active leave-to-class leave-active-class`
09:37:50.571 at lib\vant\mixins\transition.js:4
09:37:50.572 文件查找失败:'./bem.wxs' at lib\vant\wxs\utils.js:1
09:37:50.585 文件查找失败:'./memoize.wxs' at lib\vant\wxs\utils.js:3
2020-01-13 10:22
zhangdaren

zhangdaren (作者)

回复 9***@qq.com :
这个操作,我想想怎么修复哈,感谢反馈
2019-12-14 15:46
9***@qq.com

9***@qq.com

首先感谢作者的 这个工具 ,使用版本1.0.34, 我是原生小程序转uni-app mp ; 还没测试 打包, 转换后项目可以启动 图片路径手动修复 ,面面引用子组件的方法需改成 this.$refs.ref 方式 。问题:转换后修改了 子组件的方法(fooFun),但 父页面引用的方法还是(foo),对应不上。 如发生以上问题的 可参考修复
2019-12-13 16:08
zhangdaren

zhangdaren (作者)

回复 1***@163.com :
文件查找失败:'./iconfont.eot?t=1530930392525' at App.vue:7” 这个可以把路径调整一下吧,

vue-cli已很久没使用过了,多数情况还是使用默认模式吧,只需要修改页面里面的路径即可。

//avoid using JavaScript keyword as property name: "default"
//避免使用JavaScript关键字作为属性名:“default”

这个应该是某个属性使用了default作为属性名了,你查找一下代码看看
2019-11-20 14:36
1***@163.com

1***@163.com

你好,我用vue-cli方式转了以后运行报这个“12:23:10.723 Module Error (from ./node_modules/@dcloudio/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/templateLoader.js):
12:23:10.725 (Emitted value instead of an instance of Error)
12:23:10.739 Errors compiling template:
12:23:10.740 avoid using JavaScript keyword as property name: "default"
文件查找失败:'./iconfont.eot?t=1530930392525' at App.vue:7”

这个有办法吗?
2019-11-20 12:31
zhangdaren

zhangdaren (作者)

回复 7***@qq.com :
不能运行是提示什么呢?试试在左侧项目名称上点击右键-->重新识别项目类型,然后再运行。
2019-11-19 09:39
7***@qq.com

7***@qq.com

你好,我的微信小程序用你的工具转换成uni-app之后,请问怎么运行呢?在Hbuild里面点击运行,并不能运行
2019-11-18 15:20
zhangdaren

zhangdaren (作者)

回复 f***@vip.qq.com :
出现这个提示的原因是:使用了setData去给data里一个未曾声明的变量赋值,解决方案是找到那个变量,并在data里面手动声明一下(有可能是this被传到其他函数里面进行setData,这种情况,工具没法判断到,,也有可能是在请求里面,直接将返回的数据进行setData),具体需要找到对应代码进行调试才能知道
2019-11-14 10:34
f***@vip.qq.com

f***@vip.qq.com

[Vue warn]: Avoid adding reactive properties to a Vue instance or its root $data at runtime - declare it upfront in the data option. __ERROR setData 方法引起的,导致setData方法无法运行
2019-11-09 19:58