.vue中style标签里面的background问题

作者:Jasmine - 2017年04月26日

html:

<div :style="backgroundDiv" class="background-img"></div>

js:

<script>
  export default {
    data () {      return {       
        backgroundDiv: {
          backgroundImage: 'url(' + require('../assets/images/1.jpg') + ')',
        }
      }
    }
  }</script>

css:

<style scoped>
  .background-img {    
      background: no-repeat center top;  
      background-size: contain;   
      height: 150px; 
       }
</style>


来源于: https://segmentfault.com/q/1010000007709794?_ea=1433153

本文作者: Jasmine

本文链接: https://www.jianbaizhan.com/article/543.html

版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 许可协议。转载请注明出处!


 请勿发布不友善或者负能量的内容。审查将对发布广告等违规信息进行处罚!