Vue.js VueJS2:如何按顺序加载静态JS?

Vue.js VueJS2:如何按顺序加载静态JS?,vue.js,vuejs2,Vue.js,Vuejs2,我有HTML主题,使用jQuery和缩小自定义JS插件。应用程序需要首先加载jQuery,而不是小型定制JS插件。而且我不能编辑缩小的自定义JS插件 mounted() { let jqueryJS = document.createElement('script'); jqueryJS.type = 'text/javascript'; jqueryJS.src = '/static/js/jquery.js'; jqueryJS.async = false; docume

我有HTML主题,使用jQuery和缩小自定义JS插件。应用程序需要首先加载jQuery,而不是小型定制JS插件。而且我不能编辑缩小的自定义JS插件

mounted() {
  let jqueryJS = document.createElement('script');
  jqueryJS.type = 'text/javascript';
  jqueryJS.src = '/static/js/jquery.js';
  jqueryJS.async = false;
  document.body.appendChild(jqueryJS);

  let pluginsJS = document.createElement('script');
  pluginsJS.type = 'text/javascript';
  pluginsJS.src = '/static/js/plugins.js';
  pluginsJS.async = false;
  document.body.appendChild(pluginsJS);
}
如果我运行应用程序,jQuery不一定会在小型定制JS插件之前加载。 如何先加载jQuery,然后再加载缩小的自定义JS插件?

您可以使用


请分享您现在如何加载jquery。例如,如果在Vue之前使用普通脚本标记包含它,那么它肯定应该在Vue之前加载。
var$=jQuery.noConflict()
在plugins.js的顶部,我已经像导入Vue.use(VS2)一样导入了VueScript2。当我使用它时,会出现错误
[Vue warn]:挂载钩子中的错误:“ReferenceError:VueScript2未定义”
@YosuaLijantoBinar您需要在使用之前导入它。我已经编辑了答案,你可以用VS2替换VueScript2,这无关紧要,关键是Vue.use用于script2标记,而要实用地使用它,你每次都需要导入它。我可以为整个应用导入一次吗?我在
main.js
导入它,但是
VueScript2
无法在
App.vue
@yosalijantobinar上访问。你可以这样做->@yosalijantobinar你到底怎么使用?请记住,这将在以后发生变化
import VueScript2 from 'vue-script2'
...
mounted() {
  VueScript2.load('/static/js/jquery.js').then(function () {
    VueScript2.load('/static/js/plugins.js')
  })
}