vue3 常见过度
1、 首次打开页面时 loading
在页面首次打开的加载内容,是最容易的,通过根目录 index.html文件
在 当vue实例创建完成,通过 路由切换过度 需要先了解一个, 同理:( 异步组件的切换 ) 异步组件也是可以使用相同的方法 Element Plus Vue3 桌面组件库。在开发 Vue 3.x 页面时调用,使用 Element Plus 组件(如 el-button、el-input、el-form、el-table 等)。 添加过度动画需要先了解 设置样式通过 组合起来 ????
<div>
<h2>加载中......</h2>
</div>
<script></script>
.mount() 方法挂载到 id='app' 的div 里,会替换掉里的loading内容;2、 路由切换时、异步组件 loading
vue3 的内置组件 ; 提供 2 个插槽 ????;#default : 一个要加载的内容 ;#fallback: 一个加载种显示的内容;<suspense><template><router-view></router-view></template><template><h2>加载中......</h2>
</template></suspense>
<template><suspense><template><asynccomp></asynccomp></template><template><h2>加载中......</h2>
</template></suspense><button> 切换 </button>
</template><script>
import { defineAsyncComponent , ref } from 'vue';
const asyncComp = defineAsyncComponent(()=>important('./asyncComp.vue));
const vitblie = ref(false);
function open(){
vitblie.value = !vitblie.value;
}
</script>
添加过度动画
vue3 内置组件 和 ????: 非常简单只有一个 is 显示该组件, 可以用来组件切换 如: <template>
<component></component>
</template>
: 里插入的内容 显示/隐藏 添加过度动画 ,通过 name 属性来拼接 class 如 : <template>
<transition>
<testcomp></testcomp>
</transition>
</template>
name 属性 这里anime-enter-active: 过度态 ( 设置 隐藏 => 显示 过度的时间等参数)anime-leave-active: 过度态 ( 设置 显示 => 隐藏 过度的时间等参数)anime-enter-from => anime-enter-to 隐藏 => 显示 开始和结束的样式anime-leave-from => anime-leave-to 显示 => 隐藏 开始和结束的样式
<template><router-view><transition><component></component><transition></transition></transition></router-view><template><style>
.anime-enter-active,
.anime-leave-active {
transition: all 1s;
}
.anime-leave-from { transform: translateY(0); }
.anime-leave-to { transform: translateY(-100%); }
.anime-enter-from { transform: translateY(100%); }
.anime-enter-to { transform: translate(0); }
</style></template></template>
前端入门到VUE实战笔记:立即使用
在学习笔记中,你将探索 前端 的入门与实战技巧!










