Vue-cli 3:如何使用具有确定路径的静态资产?

问题描述 投票:0回答:2

我的应用有地址:

https:/firstpath.com/firstsubfolder/app.html

使用静态资产的相对路径:

https:/firstpath.com/firstsubfolder/img/image.png

如何为我的静态资产使用确定的路径?例如:

https:/secondpath.com/secondsubfolder/thirdsubfolder/img/image.png
javascript vue.js vue-cli-3
2个回答
0
投票

如果您的资产位于https://secondpath.com/secondsubfolder/thirdsubfolder但是,如果您的应用程序在另一个域上,则只需为每个资源调用具有完整URL的资源即可。

如果您的应用程序URL为https://firstdomain.com/firstapp/app.html,则可以从https://fristdomain.com/anotherdir/assets.js调用资产。


0
投票

由于您已经在使用vue cli3,因此只需在vue.config.js中设置assetsdir属性。有关更多信息,请访问https://cli.vuejs.org/config/#assetsdir

© www.soinside.com 2019 - 2024. All rights reserved.