Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parseInt 和parseFloat都用不了的? #23

Closed
callmesoul opened this issue Nov 27, 2018 · 2 comments
Closed

parseInt 和parseFloat都用不了的? #23

callmesoul opened this issue Nov 27, 2018 · 2 comments

Comments

@callmesoul
Copy link
Contributor

为什么parseIntparseFloat都用不了的?

thirdScriptError 
 sdk uncaught third Error 
 $parseFloat is not a function 
 TypeError: $parseFloat is not a function
    at Object.300 (http://127.0.0.1:14521/appservice/pages/notice/detail.js:205:22)
    at __webpack_require__ (http://127.0.0.1:14521/appservice/runtime.js:79:30)
    at Object.299 (http://127.0.0.1:14521/appservice/pages/notice/detail.js:192:19)
    at __webpack_require__ (http://127.0.0.1:14521/appservice/runtime.js:79:30)
    at Object.298 (http://127.0.0.1:14521/appservice/pages/notice/detail.js:182:1)
    at __webpack_require__ (http://127.0.0.1:14521/appservice/runtime.js:79:30)
    at Object.297 (http://127.0.0.1:14521/appservice/pages/notice/detail.js:175:18)
    at __webpack_require__ (http://127.0.0.1:14521/appservice/runtime.js:79:30)
    at Module.266 (http://127.0.0.1:14521/appservice/pages/notice/detail.js:15:100)
    at __webpack_require__ (http://127.0.0.1:14521/appservice/runtime.js:79:30)
@callmesoul
Copy link
Contributor Author

??我是要升级mina-webpack么?

@imyelo
Copy link
Member

imyelo commented Nov 28, 2018

排查出原因了。

corejs 为了在部分浏览器中(比如 IE 10-11)兼容 ES2015 中的 Number.parseInt / Number.parseFloat,将所有访问 parseInt / parseFloat 的操作都改为 从全局变量中读取
而微信小程序的环境里,并没有把这两个变量放入任何可以被开发者访问到的全局对象中 (globalwx 以及 corejs 所使用的 new Function('return this')())。

现在 mina-runtime-webpack-plugin 会在运行时脚本中自动地将这两个变量注入全局对象,应该修复了这个问题。

可以将这个包升级到 1.0.2 以上验证:

npm i --save-dev @tinajs/mina-runtime-webpack-plugin@^1.0.2

gl 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants