Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/445.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript React、webpack和Wavesurfer.js_Javascript_Reactjs_Webpack_Create React App_Wavesurfer.js - Fatal编程技术网

Javascript React、webpack和Wavesurfer.js

Javascript React、webpack和Wavesurfer.js,javascript,reactjs,webpack,create-react-app,wavesurfer.js,Javascript,Reactjs,Webpack,Create React App,Wavesurfer.js,我试图使用npmreact wavesurfer软件包,但出现了错误 this._wavesurfer.init is not a function 这似乎是因为wavesurfer未正确设置。github上的页面声明“WaveSurfer需要是一个全局可访问变量。” 我的react项目是使用create react app创建的,因此我没有网页包配置文件如何包含这些wavesurfer插件? 注意:询问同样的问题,但唯一的答案是直接使用非react,wavesurfer.js包。我更喜欢使用

我试图使用npm
react wavesurfer
软件包,但出现了错误

this._wavesurfer.init is not a function
这似乎是因为wavesurfer未正确设置。github上的页面声明“WaveSurfer需要是一个全局可访问变量。”

我的react项目是使用
create react app
创建的,因此我没有网页包配置文件如何包含这些wavesurfer插件?


注意:询问同样的问题,但唯一的答案是直接使用非react,
wavesurfer.js
包。我更喜欢使用
react wavesurfer

看起来你需要添加自定义
webpack.config.js
参数,我认为你不能在
create react app
中立即添加这些参数。如果你在谷歌上搜索,你可以使用一些工具来解决这个问题,但一个更简单的方法可能是下载你需要的相关
wavesurfer.js
文件,并将它们包含在你
index.html
中,因此它们都是在你实际加载应用程序之前加载的,因此可以在全球范围内使用,自从
react wavesurfer
不再受支持以来,似乎已经有了一系列的变化和新版本,因此使用非react wavesurfer可能不是一个坏主意
// provide WaveSurfer as a globally accessible variable
  plugins: [
    new webpack.ProvidePlugin({
      WaveSurfer: 'wavesurfer.js'
    })
  ],
  // Alias `wavesurfer` to the correct wavesurfer package.
  // (wavesurfer.js has some non-standard naming convention)
  resolve: {
    alias: {
      wavesurfer: require.resolve('wavesurfer.js')
    }
  },