14-使用Vue来实现JQuery的动画效果
2019-06-27 12:10
726 查看
原文链接:http://www.cnblogs.com/Romantic-Blood/p/11096281.html
在学Vue之前学jQuery的时候,觉得jquery可能是最好用的,比JavaScript简洁了非常多,那段时间写的所有效果都用的jquery不管是轮播图还是页面效果,用jquery都可以轻松解决,但是随着Vue的学习,我发现代码可以越来越省,jquery还需要直接操作dom来改变具体样式,而Vue直接一个methods搞定,最直接的好处就是节省了大量的代码和时间。接下来用Vue实现了一个slideDown、slideUp和show、hide效果。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="vue.min.js"></script>
</head>
<body>
<div id="app">
<my-component></my-component>
</div>
<script>
Vue.component("my-component",{
props:['width'],
template:
`<div>
<div :style="a" @mouseenter="handleA" @mouseleave="handleB"></div>
<div :style="b"></div>
</div>`,
data(){
return{
a:{
background:"deepskyblue",
width:"100px",
height:"60px",
},
b:{
background:"deeppink",
width:"100px",
height:"0",
opacity:"0",
transition:"all 5s",
// display:"none"
},
}
},
methods:{
handleA(){
this.$data.b.display="block",
this.$data.b.height="500px",
this.$data.b.width="100px",
this.$data.b.opacity="1",
this.$data.b.background="yellow"
},
handleB(){
this.$data.b.display="hide",
this.$data.b.height="0",
this.$data.b.width="100px",
this.$data.b.opacity="0",
this.$data.b.background="red"
}
},
computed:{
}
});
new Vue({
el:"#app",
data:{
}
})
</script>
</body>
</html>
转载于:https://www.cnblogs.com/Romantic-Blood/p/11096281.html
相关文章推荐
- Jquery使用animate实现css3的transform动画效果
- 使用jQuery实现的掷色子游戏动画效果
- 23、使用jQuery实现动画效果(原理:改变CSS)
- React学习笔记:使用jquery实现动画效果淡入淡出
- jquery使用CSS3实现文字动画效果插件Textillate.js
- vue2.0 中使用transition实现动画效果使用心得
- 使用jQuery来实现菜单文字和图标动画效果
- Jquery使用animate实现css3的transform动画效果
- jquery使用CSS3实现文字动画效果插件Textillate.js
- 使用HTML5和jQuery插件Reel实现一个超酷的星际争霸2兵种动画360度预览效果
- 使用jQuery实现的掷色子游戏动画效果
- 使用Vue实现jQuery的切换选中效果
- 60、实例 使用jQuery实现自定义动画效果
- 使用HTML5和jQuery插件Reel实现一个超酷的星际争霸2兵种动画360度预览效果
- vue.js使用钩子函数实现动画效果
- jquery实现新闻漂亮的动画展示效果
- 使用C#实现WinForm窗体的动画效果
- 使用HTML5和jQuery插件Quicksand实现一个超酷的星际争霸2兵种分类展示效果
- 用jquery实现选项卡效果(非常漂亮,带动画效果)
- 使用jquery实现简单的拖动效果