欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

vue的style方式绑定行内样式-background-image的方式等

程序员文章站 2022-05-15 22:44:52
...

一:

<template>
  <div id="app">
    <div class="y_bj" :style="y_bj"></div>
  </div>
</template>
<script>
import { Toast } from "vant";
export default {
  data() {
    return {
      y_bj: {
        backgroundImage: "url(" + require("@/assets/images/user_bj.png") + ")",
        backgroundRepeat: "no-repeat",
        backgroundSize: "100%",
        width: "100%",   
      }
    };
  },
  methods: {}
};
</script>
<style lang="scss" scoped>
.y_bj {
  width: 375px;
  height: 125px;
}
</style>

二:

v-bind:style="{backgroundImage:'url(' + item.videopic + ')', backgroundRepeat:'no-repeat', backgroundPosition:'center center', backgroundSize: 'contain'}"

:style="{height: showList && carList.length > 0 ? '23rem' : '0'}"

相关标签: iview vue