<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="app" class="container">
<div class="box bg-primary mt-5" :class="{ 'rotate': isTransform }"></div>
<button class="btn btn-outline-primary mt-5" @click=" isTransform = !isTransform">旋轉方塊</button>
</div>
</body>
</html>
.box {
width: 200px;
height: 200px;
transition: transform .5s;
}
.box.rotate {
transform: rotate(45deg);
}
var app = new Vue({
el: "#app",
data: {
isTransform: false
}
});