-
Notifications
You must be signed in to change notification settings - Fork 1k
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
webpack-vue-uniapp打包后,mp3.js报错_parseInt2 is not defined,beta-amr-engine.js报错Cannot read property 'slice' of null #79
Comments
参考: 晚点我尝试更新一下beta-amr-engine这个文件 |
感谢作者的回复。 现在有个新问题,就是我暂时去掉了ios微信录音的支持,此时没有报错了。 源码里没有_parseInt2 ,通过浏览器控制台查看对应的是 源码的parseInt,我截图了,麻烦看下 |
补充一下,目前依赖如下: import Recorder from 'recorder-core' |
看起来像是babel给js代码加料(投毒)了。麻烦发一下你的webpack配置(发一份能在现问题的源码就更好了,你看看能不能新建一个能一样产生问题的简单demo) |
beta-amr-engine这个文件我看了一下benz-amr-recorder的作者只更新了一次 我怀疑你那编译出来的js函数变成 function xxx(){}这种形式,导致sourceRegex不能匹配。就跟parseInt一样,被改写成了别的函数 |
我用的是DCloud的HbuilderX开发工具( 官网:https://www.dcloud.io/ ) 这个开发工具新建uniapp项目里面没有像vue-cli那样有详细的配置文件,HbuilderX虽然也是用webpack打包,但是把一些细节封装隐藏起来了 |
你那试试把下面两个地方的 Lines 254 to 258 in 6dd3e96
|
改后报错: |
recorder.zip |
dd1aafb 两个问题都已修复。 beta-amr-engine里面这段jsfunc的分解代码其实压根一点用处都没有,最外面这层函数没有地方用到了,直接剔除了这段带有隐患的源码。 parseInt应该是babel-polyfill中配置的原因,Hbuilder的锅,应该是配置了对parseInt、parseFloat的处理(全局下的parseInt又没有说会废弃,毛用处都没有,不像Promise还有点卵用这种)😂 |
感谢作者!已在uniapp上实测,问题已解决。 |
在uniapp里使用该项目时,控制台出现错误log:
beta-amr-engine.js:451 Uncaught TypeError: Cannot read property 'slice' of null
at parseJSFunc (beta-amr-engine.js:451)
at beta-amr-engine.js:458
at beta-amr-engine.js:400
at Object.../../../../../11.workspace/vueWorkSpace/supervisorUniApp/recorder-core/src/engine/beta-amr-engine.js (beta-amr-engine.js:8)
at webpack_require (bootstrap:766)
at fn (bootstrap:129)
at Object.../../../../../11.workspace/vueWorkSpace/supervisorUniApp/main.js (main.js:14)
at webpack_require (bootstrap:766)
at fn (bootstrap:129)
at Object.0 (log.js:47)
我查了这行代码 451行是这个:var parsed = jsfunc.toString().match(sourceRegex).slice(1);
求教怎么处理?
以下是我使用方式,使用nmp下载源码后,源码位于node_modules目录下,我将recorder-core(以及该文件夹的内部文件)复制到 我的uniapp项目跟目录,并在main.js中引入(如下import所示),这时在控制台就会出现 上面的 错误log,显示 beta-amr-engine 的451行报错。
import RecordApp from 'recorder-core/src/app-support/app'
import 'recorder-core'
import 'recorder-core/src/engine/mp3'
import 'recorder-core/src/engine/mp3-engine'
//ios 微信支持
import 'recorder-core/src/app-support/app-ios-weixin-support'
import 'recorder-core/ios-weixin-config.js'
import 'recorder-core/src/engine/beta-amr'
import 'recorder-core/src/engine/beta-amr-engine'
The text was updated successfully, but these errors were encountered: