I'm new to ReactTS. Now I need to insert a web page written in native JS and HTML into a react project.
The code is as follows:
export default class OpenDrive extends React.PureComponent {
override componentDidMount() {
const src1 = document.createElement('script');
src1.type = 'text/javascript';
src1.async = true;
src1.src = './Viewer/ModuleOpenDrive.js';
document.body.appendChild(src1);
}
override render() {
return (
<div style={{ height: '100%', width: '100%' }}>
<div id="ThreeJS" style={{ height: '100%', width: '100%' }}></div>
<div className="popup_info bottom_info" id="spotlight_info"></div>
<input id="xodr_file_input" type="file" style={{ visibility: 'hidden' }} />
</div>
);
}
}
The script tag has been successfully loaded on the browser, but with value $0. The script inserted in this way seems to only support JS code on the network, not local.
Is there any way for me to run local JS code here?