[英]handle data attributes with webpack and vuejs
I use the vue cli with webpack and I'm absolutely fine with it. 我使用带有webpack的vue cli,我对它非常好。 But now I have a little problem! 但现在我有一点问题!
I want that the path in the data
attributes from the <object>
tags are also compiled like the src
attributes from the <img>
tags 我希望<object>
标签的data
属性中的路径也像<img>
标签中的src
属性一样编译
for example: 例如:
If I do something like this 如果我做这样的事情
<img src="../path/to/file.svg" alt="">
webpack compiled the path to webpack编译了路径
<img src="/dist/path/to/file.svg" alt="">
but when I do something like this: 但是当我做这样的事情时:
<object type="image/svg+xml" data="../path/to/file.svg">fallback</object>
it doesn't work :( 它不起作用:(
Use the require()
helper 使用require()
帮助器
Example: 例:
<object :data="require(`../path/to/file-${if-you-need-to-pass-a-variable-here}.svg`)" type="image/svg+xml" >fallback</object>
<img :src="require(`../path/to/file-${if-you-need-to-pass-a-variable-here}.svg`)" alt="">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.