更新
我换了
import {WaveSurfer} from "js/wavesurfer.js/src/wavesurfer.js"
经过
import WaveSurfer from "./js/wavesurfer.js/src/wavesurfer.js"
现在似乎已导入,但我现在收到以下错误:
SyntaxError: bad method definition (wavesurfer.js:179:4)
(请参见此处的相应行)
我正在尝试从wavesurfer.js运行一个示例,其中包含代码的本地克隆。
使用下面显示的代码,我得到
SyntaxError: import declarations may only appear at top level of a module (wavesurfer.js:1)
按照此处给出的建议,我将第一行替换index.html
为
<script type='module'>
import {WaveSurfer} from "js/wavesurfer.js/src/wavesurfer.js"
</script>
并得到
ReferenceError: WaveSurfer is not defined (zoom.js:1:5)
TypeError: Error resolving module specifier: js/wavesurfer.js src/wavesurfer.js index.html:4:25
我应该如何导入WaveSurfer
?
索引.html
<script src="js/wavesurfer.js/src/wavesurfer.js"></script>
<script src="js/zoom.js"></script>
<div id="waveform"></div>
...
缩放.js
var wavesurfer = WaveSurfer.create({
container: '#waveform',
waveColor: 'red',
progressColor: 'purple'
});
wavesurfer.load('https://ia902606.us.archive.org/35/items/shortpoetry_047_librivox/song_cjrg_teasdale_64kb.mp3');
...