How to ensure that the JS introduced by the script tag has been loaded in VUE?

clipboard.png
vuescript JS,

mounted js

clipboard.png

script js ,,

clipboard.png
so, to fix this BUG, you must make sure that the external js is loaded, but I don"t know how to make sure that the JS is loaded. May I ask the gods how to do this?


listen for onload events

var scriptEle = document.createElement('script')
scriptEle.onload = function() {
    console.log('')
}
document.body.appendChild(scriptEle)

Thank you for the invitation!

< hr >

it is recommended to introduce echarts into main.js and register on the prototype of vue !
1, npm install echarts-- save
2, in main.js :

import echarts from 'echarts';
Vue.prototype.$echarts = echarts;

3. You can now get $echarts

registered to the prototype in the global vue . < hr >

A suggestion: generally echarts needs to be initialized before use, so initialization is best done in vue :

mounted() {
    //
    //documentidref
    //ref
    this.obj_echarts = this.$echarts.init(document.getElementById('xxx'));
},
data(){
    return {
        obj_echarts: null
    }
}
< hr >
I hope my answer will be helpful to you!

Modern browsers are supposed to load js sequentially, so the js in head is bound to load before the js that webpack packages and inserts.

simple code verification is as follows:

  https://webpack.js.org/config.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf40a2-54b24.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf40a2-54b24.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?