0
点赞
收藏
分享

微信扫一扫

学习vue笔记(4)

40dba2f2a596 2022-02-13 阅读 55

目录

props配置

minin混入

插件

scoped

Todo案例--初始化列表

浏览器本地存储

自定义事件--绑定

自定义事件--解绑

自定义事件--总结

全局事件总线

消息订阅与发布

实现编辑内容

动画效果

过渡效果

多个元素过渡

集成第三方动画

动画过渡总结

认识路由

路由基本使用


props配置

组件的复用

为了解决复用产生的问题,可以进行类型限制

最完整的写法(非常少用)

总结

 minin混入

 

 

 总结

 插件

 

 

插件允许带参数

总结 scoped

Todo案例--初始化列表

浏览器本地存储

 

 

 

 

 

 

 

自定义事件--绑定

父组件监控子组件事件,完成子组件给父组件传递数据

 这里第六行,on改once,只执行一次

 

 

 

 自定义事件--解绑

 

 

解绑:可以用$off

自定义事件--总结

 6、、

 2、、回调必须在App.vue父组件内

 全局事件总线

所有都可以找到的--vue

 

简写 

 在组件里面可以挂载

 

 

 总结

 在todo中

 

 

 消息订阅与发布

 

 总结

 实现编辑内容

 

 总结

 

 动画效果

 加了appear,在开启网页时就有动画效果

 

Test.vue

<template>
<div>
<button @click="isShow = !isShow">显示/隐藏</button>
<transition appear>
<h1 v-show="isShow">你好哇</h1>
</transition>
</div>
</template>
<script>
export default {
name: "Test",
data() {
return {
isShow: true,
};
},
};
</script>
<style scoped>
h1 {
background-color: orange;
}
.v-enter-active {
animation: yihihi 0.5s linear;
}
.v-leave-active {
animation: yihihi 0.5s reverse;
}
@keyframes yihihi {
from {
transform: translateX(-100%);
}
to {
transform: translateX(0px);
}
}
</style>

 


APP.vue
<template>
<div>
<Test />
</div>
</template>
<script>
import Test from "./components/Test";
export default {
name: "App",
components: {
Test,
},
};
</script>
<style>
</style>

过渡效果

 

<template>
<div>
<button @click="isShow = !isShow">显示/隐藏</button>
<transition-group name="hello" appear>
<h1 v-show="isShow" key="1">你好哇</h1>
<h1 v-show="!isShow" key="2">hhh</h1>
</transition-group>
</div>
</template>

<script>
export default {
name: "Test",
data() {
return {
isShow: true,
};
},
};
</script>

<style>
h1 {
background-color: orange;
}
/* 进入的起点、离开的终点 */
.hello-enter,
.hello-leave-to {
transform: translateX(-100%);
}
.hello-enter-active,
.hello-leave-active {
transition: 0.5s linear;
}
.hello-enter-to,
.hello-leave {
transform: translateX(0);
}
</style>

多个元素过渡


<template>
<div>
<button @click="isShow = !isShow">显示/隐藏</button>
<transition-group name="hello" appear>
<h1 v-show="isShow" key="1">你好哇</h1>
<h1 v-show="!isShow" key="2">hhh</h1>
</transition-group>
</div>
</template>
<script>
export default {
name: "Test",
data() {
return {
isShow: true,
};
},
};
</script>
<style>
h1 {
background-color: orange;
}
/* 进入的起点、离开的终点 */
.hello-enter,
.hello-leave-to {
transform: translateX(-100%);
}
.hello-enter-active,
.hello-leave-active {
transition: 0.5s linear;
}
.hello-enter-to,
.hello-leave {
transform: translateX(0);
}
</style>

 

 集成第三方动画

在npm网站中查找animate.css引入

 

 

<template>
<div>
<button @click="isShow = !isShow">显示/隐藏</button>
<transition-group
name="animate__animated animate__bounce"
appear
enter-active-class="animate__rubberBand"
leave-active-class="animate__bounceOut"
>

<h1 v-show="isShow" key="1">你好哇</h1>
<h1 v-show="!isShow" key="2">hhh</h1>
</transition-group>
</div>
</template>

<script>
import "animate.css";
export default {
name: "Test",
data() {
return {
isShow: true,
};
},
};
</script>

<style>
h1 {
background-color: orange;
}
/* 进入的起点、离开的终点 */
.hello-enter,
.hello-leave-to {
transform: translateX(-100%);
}
.hello-enter-active,
.hello-leave-active {
transition: 0.5s linear;
}
.hello-enter-to,
.hello-leave {
transform: translateX(0);
}
</style>

动画过渡总结

 

 认识路由

 

 

 

举报

相关推荐

0 条评论