我想在反应上画一个五线谱,我正在阅读使用 EasyScore:Vexflow 官方教程
下面是我的反应代码。
import React, { useRef, useEffect , useState } from 'react'
import Vex from 'vexflow'
import './App.css'
export default function App()
{
const VF = Vex.Flow;
var vf = new VF.Factory({renderer: {elementId: 'boo'}});
var score = vf.EasyScore();
var system = vf.System();
system.addStave({
voices: [score.voice(score.notes('C#5/q, B4, A4, G#4'))]
}).addClef('treble').addTimeSignature('4/4');
vf.draw();
return (
<div id="boo"></div>
)
}
我在反应 TypeError 中遇到错误:this.element.appendChild is not a function
new SVGContext
C:/easyscore/KAISTcamp-project3-Server/example/node_modules/vexflow/src/svgcontext.js:41
38 | this.svgNS = 'http://www.w3.org/2000/svg';
39 | const svg = this.create('svg');
40 | // Add it to the canvas:
> 41 | this.element.appendChild(svg);
| ^ 42 |
43 | // Point to it:
44 | this.svg = svg;
我的一些代码涉及
App
C:/easyscore/KAISTcamp-project3-Server/example/src/App.js:8
5 | export default function App()
6 | {
7 | const VF = Vex.Flow;
> 8 | var vf = new VF.Factory({renderer: {elementId: 'boo'}});
9 | var score = vf.EasyScore();
10 | var system = vf.System();
11 |
Module.<anonymous>
C:/easyscore/KAISTcamp-project3-Server/example/src/index.js:7
4 | import App from './App';
5 | import reportWebVitals from './reportWebVitals';
6 |
> 7 | ReactDOM.render(
8 | <React.StrictMode>
9 | <App />
10 | </React.StrictMode>,
我会很感激你的帮助。请给我一些建议。