效果图太晃眼了 放封面了
代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<title>过渡动画</title>
</head>
<style>
.movearea{
color: white;
height: 200px;
padding: 1rem;
transition: 0.2s background-color ease;
}
</style>
<body>
<div id="root">
<h3 @mousemove="xChange" :style="{background:`hsl(${x},80%,50%)`}" class="movearea">左右滑动鼠标</h3>
<p>x:{{x}}</p>
</div>
</body>
<script>
const app = Vue.createApp({
setup(){
const {ref} = Vue;
let x = ref(0);//{value:0}
const xChange = (e) =>{
x.value=e.clientX
}
return{
x,
xChange
}
}
});
const vm = app.mount("#root");
</script>
</html>