Я пытаюсь вызвать внутренний компонент Brains.js из CDN Brain.js, вот что у меня есть в моем коде App.js:
import { useEffect } from 'react';
import logo from './logo.svg';
import './App.css';
function App() {
useEffect(() => {
test();
// ...
}, [])
function test() {
const script = document.createElement('script');
script.src = "https://unpkg.com/brain.js";
script.async = true;
console.log("script");
document.body.appendChild(script);
var net = new brain.recurrent.LSTM()
net.train([
'doe, a deer, a female deer',
'ray, a drop of golden sun',
'me, a name I call myself',
], {
iterations: 1500,
log: details => console.log(details),
errorThresh: 0.011
});
var output = net.run('doe') // ', a deer, a female deer'
const myOutput = document.querySelector('#myOutput');
myOutput.innerHTML = output;
console.log(output)
}
return (
);
}
export default App;
И я получаю эту ошибку:
ERROR in [eslint]
src\App.js
Line 9:27: 'brain' is not defined no-undef
Выполните поиск по ключевым словам, чтобы узнать больше о каждой ошибке.
Ошибка консоли в веб-браузере:
ERROR in [eslint]
src\App.js
Line 9:27: 'brain' is not defined no-undef
Подробнее здесь: https://stackoverflow.com/questions/793 ... g-an-error