我正在学习 VueJs,但我被阻止了。 我的问题是,我不知道需要为组件 css 部分上的背景图像属性的 url 指定哪个路径。
<template>
<div class="layer"></div>
<template>
<script>
export default {
name: 'Layer'
}
</script>
<style lang="scss">
.layer{
background-image: url(../public/images/myImage.jpg)
}
</style>
我需要输入什么网址? 我的图像位于“public/images/myImage.jpg” 我的组件层位于 'src/components/Layer.vue'
谢谢
最佳答案
如果你的img是公开的,只需写为相对路径:
.layer{
background-image: url('/images/myImage.jpg')
}
关于css - VueJS背景图像url找不到路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61035366/