vue中data属性动态绑定style样式

  data: function () {
        return {
          picItem: ["./a1.jpg", "./a1.jpg", "./a1.jpg", "./a1.jpg", "./a1.jpg", "./a1.jpg", "./a1.jpg", "./a1.jpg"],
          picShow: {
            height: "100px",
            width: ""
          },
        }
      },
mounted() {
        this.picShow.width=this.getWidth()
      },
methods: {
         getWidth() {
          let index = this.picItem.length
          let num = Number(index) * 120 + "px"
          return num
        },
  }

你可能感兴趣的:(vue,vue)