how to to insert TradingView widget into react js which is in script tag link: https://www.tradingview.com/widget/market-overview/

前端 未结 4 951
星月不相逢
星月不相逢 2021-01-13 10:48
export default class extends Component {
    render() {
        return (
            
{ /***
4条回答
  •  说谎
    说谎 (楼主)
    2021-01-13 11:28

    This should work in your case

    class App extends  React.Component {
    
        componentDidMount() {
            const script = document.createElement('script');
            script.src = 'https://s3.tradingview.com/external-embedding/embed-widget-market-overview.js'
            script.async = true;
            script.innerHTML = JSON.stringify({ /* JSON object */})
            document.getElementById("myContainer").appendChild(script);
        }
    
        render() {
            return(
          
    ); } }

提交回复
热议问题