我正在使用 simple-webpack vuecli 来实现我的网站。我有一个按钮,它有一个 :after modified 产生一个带有背景路径 url 的内容。我如何在 css 中的 background-url 上使用 require
?似乎内联样式不适用于 :after css modified。
全局 SCSS
.btn-green .btn-text:after{
content: "";
width: 7px;
height: 10px;
background: url('/assets/img/svg/arrow-right.svg') no-repeat 0 0;
background-size: 100%;
display: inline-block;
margin-left: 5px;
padding-bottom: 11px;
}
Vue 模板
<div class="btn-green universal-shadow">
<div class="btn-text">GET STARTED</div>
</div>
最佳答案
您需要使用相对路径,否则 Webpack 会将其解释为实际 URL,而不是它应该需要的模块路径。
url('assets/img/svg/arrow-right.svg')
^ removed the leading /
关于html - 我如何呈现背景 url CSS :after modified in VueJS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46842486/