VUE资产图像URL自动更改
我将获得我在VUE项目中使用的图像,作为另一个项目的URL。当我这样称呼它时,Vue一侧没问题:
<v-img
class="header__logo"
lazy-src="@/assets/images/mail.jpg"
src="@/assets/images/mail.jpg"
alt="Logo"
></v-img>
当我从浏览器中查看URL时,我看到已添加了大胆标记的位置,并且我看到每次发布时都会更改此代码。
http:// localhost:8081/img/mail。 3D6D7034 .jpg
我如何设置此设置以不更改?
I will get an image that I use in Vue project as url from another project. No problem on vue side when I call it like this :
<v-img
class="header__logo"
lazy-src="@/assets/images/mail.jpg"
src="@/assets/images/mail.jpg"
alt="Logo"
></v-img>
When I look at the url from the browser, I see that the place marked in bold has been added and I see that this code changes every time we release.
http://localhost:8081/img/mail.3d6d7034.jpg
How can I set this to not change?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的资产文件名称是什么?
Assets 在Vue-Cli/Nuxt 2项目中使用WebPack 捆绑(更具体地说, Asset-Module 。这意味着它们被包含在代码块中,以减少HTTP请求和大小。
在捆绑时, WebPack模块还包括放射的文件名中的哈希。这就是为什么该部分在每个构建中都会改变的原因。
解决方案:如果您需要此映像文件具有静态名称,则可以将其包含在
public/
文件夹中。它不会通过webpack,并且不会更改其名称。这样做的缺点是您必须使用文件的绝对路径,它使用
@/assets /....不再相对。
What is that hash in my asset file name?
Assets in a vue-cli / nuxt 2 project are bundled using webpack (more specifically the asset-module. That means they are included into a code chunk to reduce http requests and size.
While bundling, the webpack module also includes a hash into the emitted file name. That's why this part changes over every build.
Solution: If you require this image file to have a static name, you can include it into your
public/
folder instead.It won't go through webpack, and its name will not be altered. The downside of this is that you have to use the absolute path of the file, it's not longer relative using
@/assets/...
.