赞
踩
综合了一下网上所找到的各种方法及遇到的坑,经过试验,截止2020-01-30,本文所述方法可用
- npm install esprima
-
- npm install css-tree
-
- npm install cssbeautify
-
- npm install vm2
-
- npm install uglify-es
-
- npm install js-beautify
node .\wuWxapkg.js xxx.wxapkg
其中,xxx.wxapk为小程序包,如果不在wuWxapkg同目录,则前面需要加上路径。
1. 提示 __vd_version_info__ is not defined,则需要将wuWxss.js中runVM函数修改为:
- function runVM(name, code) {
-
- let wxAppCode = {};
- let handle = {cssFile: name};
- let gg = new GwxCfg();
- let tsandbox = {
- $gwx: GwxCfg.prototype["$gwx"],
- __mainPageFrameReady__: GwxCfg.prototype["$gwx"], //解决 $gwx is not defined
- __vd_version_info__: GwxCfg.prototype["$gwx"], //解决 __vd_version_info__ is not defined
- __wxAppCode__: wxAppCode,
- setCssToHead: cssRebuild.bind(handle)
- }
-
- let vm = new VM({sandbox: tsandbox});
- vm.run(code);
- for (let name in wxAppCode) {
- if (name.endsWith(".wxss")) {
- handle.cssFile = path.resolve(frameName, "..", name);
- wxAppCode[name]();
- }
- }
- }

2. 提示magic number is not correct,此时,考虑是否使用了微信电脑版中的wxapk包了,换安装模拟器中的包试试。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。