wepy icon indicating copy to clipboard operation
wepy copied to clipboard

wepy2.0项目在开发者工具中勾选ES6转ES5后会报Function(...) is not a function

Open ainicui opened this issue 4 years ago • 8 comments

以前wepy2.0项目重新npm install后 以及 新建的wepy2.0项目,在开发者工具中勾选ES6转ES5后会报Function(...) is not a function,并且页面不显示,不勾选则正常显示。 开发者工具:1.02.1911180 wepy版本:2.0.0-alpha.13 和 2.0.0-alpha.15 望解答,十分感谢

ainicui avatar Mar 21 '20 12:03 ainicui

try { regeneratorRuntime = runtime; } catch (accidentalStrictMode) { // This module should not be running in strict mode, so the above // assignment should always work unless something is misconfigured. Just // in case runtime.js accidentally runs in strict mode, we can escape // strict mode using a global Function call. This could conceivably fail // if a Content Security Policy forbids using Function, but in that case // the proper solution is to fix the accidental strict mode problem. If // you've misconfigured your bundler to force strict mode and applied a // CSP to forbid Function, and you're not willing to fix either of those // problems, please detail your unique predicament in a GitHub issue. Function("r", "regeneratorRuntime = r")(runtime); } 上面代码是在编译好的vendor.js中的,把上面的代码注释掉后,微信开发者工具勾选ES6转ES5,页面会正常显示,否则不注释就会报Function(...) is not a function,并且页面不显示。 不知道具体原因,希望知道原因的解答一下,不然每次编译完还要手动注释代码。

ainicui avatar Mar 22 '20 03:03 ainicui

如果你用 npm run build 之後,就不要 ES6 轉 ES5了,已經轉過了。

chenillen avatar Mar 25 '20 02:03 chenillen

这个功能babel已经做了啊,不需要再选择转es5的

kvchen95 avatar Apr 01 '20 07:04 kvchen95

这个功能babel已经做了啊,不需要再选择转es5的 不选择是不行的,你看下我这个图片里面的,不选择就会报错。 image

ainicui avatar Apr 01 '20 08:04 ainicui

这个功能babel已经做了啊,不需要再选择转es5的

但是不转的话。我项目中的promise是不能用的,直接报错了

这个功能babel已经做了啊,不需要再选择转es5的

但是不转的话。我项目中的promise是不能用的,直接报错了

实在不行的话用一下promise-polyfill,按道理promise是支持的

kvchen95 avatar Apr 01 '20 08:04 kvchen95

这个功能babel已经做了啊,不需要再选择转es5的

但是不转的话。我项目中的promise是不能用的,直接报错了

这个功能babel已经做了啊,不需要再选择转es5的

但是不转的话。我项目中的promise是不能用的,直接报错了

实在不行的话用一下promise-polyfill,按道理promise是支持的

好像不是不支持promise而是没有支持ES6的模块功能 image

ainicui avatar Apr 01 '20 09:04 ainicui

try { regeneratorRuntime = runtime; } catch (accidentalStrictMode) { // This module should not be running in strict mode, so the above // assignment should always work unless something is misconfigured. Just // in case runtime.js accidentally runs in strict mode, we can escape // strict mode using a global Function call. This could conceivably fail // if a Content Security Policy forbids using Function, but in that case // the proper solution is to fix the accidental strict mode problem. If // you've misconfigured your bundler to force strict mode and applied a // CSP to forbid Function, and you're not willing to fix either of those // problems, please detail your unique predicament in a GitHub issue. Function("r", "regeneratorRuntime = r")(runtime); } 上面的代码是在编译好的vendor.js中的,把上面的代码注释掉后,微信开发者工具插入ES6转ES5,页面会正常显示,否则不注释就会报Function(...)一个功能,并且页面不显示。不知道具体原因,希望知道原因的解答一下,不然每次编译完还要手动注释代码。

没有开es6到es5,真机调试和体验版都正常,就一个苹果手机提示这个报错,是什么原因呢?

godo9 avatar Jun 04 '20 03:06 godo9

你报错的最后那句话是画蛇添足,造成ES6和es5混着写。把你箭头所指的new函数改一下。new http()这明显不是Es5啊。

anuxs avatar Aug 26 '20 04:08 anuxs