【问题标题】:VueJS background-image url not finding the pathVueJS背景图像网址找不到路径
【发布时间】:2020-07-17 00:12:54
【问题描述】:

我正在学习 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'

谢谢

【问题讨论】:

    标签: css vue.js url background-image vue-cli


    【解决方案1】:

    如果你的img是公开的,就写成相对路径:

    .layer{
      background-image: url('/images/myImage.jpg')
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-15
      • 2013-06-13
      • 2015-09-13
      • 2019-01-31
      • 1970-01-01
      • 2011-01-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多