美文网首页
图片预览旋转按钮

图片预览旋转按钮

作者: 戒烟少年 | 来源:发表于2021-09-22 10:48 被阅读0次
<img
        width="100%"
        :src="dialogImageUrl"
        alt=""
        ref="imgInfo"
        @click="goimg(dialogImageUrl)"
      />
      <div
        style="
          display: flex;
          justify-content: space-between;
          margin: 0 auto;
          width: 100px;
        "
      >
        <i
          class="el-icon-refresh-right"
          style="font-size: 28px; cursor: pointer"
          @click="translateR"
        ></i>
        <i
          class="el-icon-refresh-left"
          style="font-size: 28px; cursor: pointer"
          @click="translateL"
        ></i>
      </div>

  data() {
    return {
      deg:0
    }
  }
methods:{
    //右转
     translateR() {
      this.deg += 90
      if (this.deg >= 360) {
        this.deg = 0
      }
      this.$refs.imgInfo.style.transform = `rotate(${this.deg}deg)`
    },
    //左转
    translateL() {
      if (this.deg <= 0) {
        this.deg = 360
      }
      this.deg += -90
      this.$refs.imgInfo.style.transform = `rotate(${this.deg}deg)`
    },
}

相关文章

网友评论

      本文标题:图片预览旋转按钮

      本文链接:https://www.haomeiwen.com/subject/xsbwgltx.html