javascript - React、webpack 和 Wavesurfer.js
问题描述
我正在尝试使用 npmreact-wavesurfer
包,但得到错误
this._wavesurfer.init is not a function
这似乎是因为 wavesurfer 设置不正确。github 上的“先决条件和常见陷阱”页面指出“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')
}
},
我的 react 项目是用创建的,create-react-app
所以我没有 webpack 配置文件。 如何包含这些 wavesurfer 插件?
注意: 这个问题问的是同样的事情,但唯一的答案是直接使用非反应wavesurfer.js
包。我宁愿使用react-wavesurfer
.
解决方案
推荐阅读
- github - 我无法将 node_modules 文件夹上传到 github
- php - 无法在运行时更改配置值,更改不会保存。拉拉维尔 8
- c# - 如何在不使用任何系统辅助函数的情况下将 byte[] 转换为 c# 中的 int?
- html - 如何根据 CSS 中的 2 种内联样式选择元素?
- sql - SQLite – 在 WHERE 子句中重用 SELECT 子句中的值的问题
- java - lambda表达式和简单方法形式的两种实现之间的区别?
- kubernetes - 从 ingress 迁移到 istio 时找不到 404
- python - 如何使用 M1chip 在我的 Mac 上运行 pyqt5
- boost - 为 websocket 提升堆栈协程,如何发布函数并从另一个线程恢复
- powerbi - 我可以在 Power BI 的组合图中将线放在两个轴上吗?(除了列)