2024年06月16日 建站教程
安装vue-rotate插件
npm install vue-rotate --save
vue图片旋转功能具体代码:
// MyComponent.vue
<template>
<div>
<img :src="/staticimgSrc" v-rotate:deg="rotatedDegree" />
<button @click="rotate">旋转</button>
</div>
</template>
<script>
import VueRotate from 'vue-rotate';
export default {
directives: {
Rotate: VueRotate
},
data() {
return {
imgSrc: '', // 图片路径
rotatedDegree: 0 // 旋转角度
}
},
methods: {
rotate() {
this.rotatedDegree += 90; // 每次点击旋转90度
}
}
};
</script>
本文链接:http://so.lmcjl.com/news/6678/