学习vue笔记(4)

目录

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>

动画过渡总结

 

 认识路由

 

 

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值