vue.js - include a static javascript on vue-cli 3 - Stack Overflow

I have a vue-cli-3 project, but i'd like to add a static javascript file, but I don't know ho

I have a vue-cli-3 project, but i'd like to add a static javascript file, but I don't know how import this file.

the traditional way is:

<script src="js/myfile.js"></scrip>

I have a vue-cli-3 project, but i'd like to add a static javascript file, but I don't know how import this file.

the traditional way is:

<script src="js/myfile.js"></scrip>
Share Improve this question asked Feb 23, 2019 at 23:55 Jonnathan CarrascoJonnathan Carrasco 1661 silver badge9 bronze badges 2
  • Please describe in greater detail what you have tried and what the oute was. – U. Windl Commented Feb 24, 2019 at 1:39
  • try in public/index.html – trueChazza Commented Feb 24, 2019 at 11:08
Add a ment  | 

1 Answer 1

Reset to default 6

Place your file (myfile.js) inside your src directory, for example in assets. In your src/App.vue file add in the script portion:

import './assets/myfile.js';

Note that you can technically put your file in public and reference it from your index.html like you usually do. It will work. But it's not the remended approach.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745459869a4628658.html

相关推荐

  • vue.js - include a static javascript on vue-cli 3 - Stack Overflow

    I have a vue-cli-3 project, but i'd like to add a static javascript file, but I don't know ho

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信