I want to reference an external js file in the js file of react. How should I write it?

I want to reference this js file

<script src="https://img.codeshelper.com/upload/img/2021/03/29/bfufrb0j1wn14072.png";

class Basic extends React.Component {

    constructor() {
        super();
        this.state = {
            isShowAll: false
        }
    }

    render() {
        return (
            <div className={"content_div"}>
                <div className={"content_img"}>
                    <div className={"content_word"}>
                        <div className={"content_join"}></div>
                        <div className={"content_join_word"}> </div>
                    </div>
                </div>

            </div>
        )
    }
}

export default Basic;

Mar.29,2021

The processing in

react-amap is like this. You can refer to:

// 
new APILoader({
    key: props.amapkey,
    useAMapUI: props.useAMapUI,
    version: props.version,
    protocol: props.protocol
}).load().then(() => {

})

APILoader.js Code https://github.com/ElemeFE/react-amap/blob/next/components/utils/APILoader.js


provides an idea to add a script tag to the DOM before the component is loaded.

  const s = document.createElement('script');
  s.type = 'text/javascript';
  s.src = 'http://baidu.com/asasasasasa/.....';
  document.body.appendChild(s);

is referenced in index.html, that is, html



is in index.html. If you don't believe it, introduce a jQ test, and then print $and you should be able to print something

.
Menu