简体   繁体   English

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

[英]Vue-cli 3: how to use static assets with determined path?

My app has address:我的应用程序有地址:

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

Using relative paths my static assets go to:使用我的 static 资产 go 的相对路径到:

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

How can I use a determined path for my static assets instead?如何改为为我的 static 资产使用确定的路径? For example:例如:

https:/secondpath.com/secondsubfolder/thirdsubfolder/img/image.png

If your assets are on https://secondpath.com/secondsubfolder/thirdsubfolder But if your app is on another domain, you just have to call your assets with full URL for each one.如果您的资产位于https://secondpath.com/secondsubfolder/thirdsubfolder但如果您的应用程序位于另一个域中,则只需为每个资产调用完整的 URL 即可。

If you application URL is https://firstdomain.com/firstapp/app.html there you'll be able to call assets from https://fristdomain.com/anotherdir/assets.js for example. If you application URL is https://firstdomain.com/firstapp/app.html there you'll be able to call assets from https://fristdomain.com/anotherdir/assets.js for example.

Since you are already using vue cli3 just set the assetsdir property in your vue.config.js.由于您已经在使用 vue cli3,只需在 vue.config.js 中设置assetsdir属性。 More info is available at https://cli.vuejs.org/config/#assetsdir更多信息可在https://cli.vuejs.org/config/#assetsdir 获得

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

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