简体   繁体   English

导入 javascript 文件在 Vue 中不起作用

[英]Import a javascript file is not working in Vue

I'm using a bootstrap theme for my Vue.js app.我正在为我的 Vue.js 应用程序使用引导主题。 So the theme contains some.css file that I suceed to import but I don't now how to import the.js files.所以主题包含一些我成功导入的.css 文件,但我现在不知道如何导入.js 文件。

I'm using我在用着

mounted() {
    let adminLTE = document.createElement("script");
    adminLTE.setAttribute("src", "./assets/js/adminlte.js");
    document.head.appendChild(adminLTE);
  },

in App.vue but when I analyze the sources in my Google Chrome console I don't see the contains of the file and I can't use the functions of the file:在 App.vue 中,但是当我在 Google Chrome 控制台中分析源代码时,我看不到文件的包含内容,也无法使用文件的功能:

控制台视图

I don't understand what I'm doing wrong, can someone help me please?我不明白我做错了什么,有人可以帮助我吗?

Thanks in advance提前致谢

If your using a bundling engine like vite, parcel, webpack and others, you could just import it as a regular module into the vue component如果您使用的是 vite、parcel、webpack 等捆绑引擎,您可以将其作为常规模块导入 vue 组件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM