图片旋转预览

2017-10-18  本文已影响0人  welcomeHere

1.dom

<div>
    <div class="rotate-icon">
        ![](/src/assets/image/rotate_r.png)
        ![](/src/assets/image/rotate_r.png)
    </div>
    <div>
        ```
            ![](filePath)
        ```
        ![](filePath)
    </div>
</div>

2.js

引入jquery旋转插件
<script src="/src/assets/js/jquery.rotate.js"></script>
// 旋转图片
rotateImg(type) {
    let rot = this.rot;
    if (type == "left") {
        if (rot === -360) {
            rot = 0;
        }
        rot -= 90;
        $("#rotImg").rotate(-90);
    }
    if (type == "right") {
        if (rot === 360) {
            rot = 0;
        }
        rot += 90;
        $("#rotImg").rotate(90);
    }
    this.rot = rot;
},
上一篇下一篇

猜你喜欢

热点阅读