1 回答
TA贡献1796条经验 获得超10个赞
您可以使用scriptjs
import $script from 'scriptjs';
class TaskLists extends Component {
UNSAFE_componentWillMount () {
$script(['https://YOUR_SCRIPT_URL_HERE'], 'scriptidentifier');
}
render () {
return (<div>Hello</div>)
}
}
来自文档 https://www.npmjs.com/package/scriptjs 的示例
// load jquery and plugin at the same time. name it 'bundle'
$script(['jquery.js', 'my-jquery-plugin.js'], 'bundle')
// load your usage
$script('my-app-that-uses-plugin.js')
/*--- in my-jquery-plugin.js ---*/
$script.ready('bundle', function() {
// jquery & plugin (this file) are both ready
// plugin code...
})
/*--- in my-app-that-uses-plugin.js ---*/
$script.ready('bundle', function() {
// use your plugin :)
})
添加回答
举报