[英]How do I add an external .js file to my index.html? (VueJS2)
So I have two external Javascript files for handling the animations and triangulation of vectors for a background animation. 因此,我有两个外部Javascript文件,用于处理背景动画的动画和矢量的三角剖分。 Now, in a normal html/css/js project I would just include those two .js
files in a <script src="fileLoc.."></script>
before the end of the </body>
tag in my regular index.html
file. 现在,在普通的html / css / js项目中,我将在常规index.html
</body>
标记末尾的<script src="fileLoc.."></script>
包含这两个.js
文件<script src="fileLoc.."></script>
index.html
文件。 My question is, how do I include those two .js
files into my VueJS2 project's index.html
file? 我的问题是,如何将这两个.js
文件包含到VueJS2项目的index.html
文件中? Just puttin <script>
tags before the </body>
end does absolutely nothing. 只是将</body>
末尾的<script>
标记放在绝对不起作用。
Thanks in advance 提前致谢
You can add another entry
point and give it a name using webpack chain
in your vue.config.js
. 您可以在vue.config.js
使用webpack chain
添加另一个entry
点并为其命名。 This will automagically be inserted in your index.html
file: 这将自动插入到您的index.html
文件中:
// vue.config.js
module.exports = {
chainWebpack: (config) => {
config
.entry('delaunay')
.add('src/assets/delaunay.js')
.end()
}
}
This should work for you in practice. 实际上,这应该对您有用。
in your js file you can do this: 在您的js文件中,您可以执行以下操作:
import delaunay from './src/assets/delaunay.js'
import bg from './src/assets/bg.js'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.