当前位置: 首页 > news >正文

政府网站建设 国务院深圳互联网推广公司

政府网站建设 国务院,深圳互联网推广公司,做cpa推广用哪种网站好,素材网站可以做淘宝吗一、基本用法 <Transition> 是一个内置组件&#xff0c;这意味着它在任意别的组件中都可以被使用&#xff0c;无需注册。它可以将进入和离开动画应用到通过默认插槽传递给它的元素或组件上。进入或离开可以由以下的条件之一触发&#xff1a; 由 v-if 所触发的切换由 v-…

一、基本用法

<Transition> 是一个内置组件,这意味着它在任意别的组件中都可以被使用,无需注册。它可以将进入和离开动画应用到通过默认插槽传递给它的元素或组件上。进入或离开可以由以下的条件之一触发:

  • v-if 所触发的切换
  • v-show 所触发的切换
  • 由特殊元素 <component> 切换的动态组件

1.1 最基本用法的示例

<template><button @click="show = !show">Toggle</button><Transition><p v-if="show">hello</p></Transition>
</template>
<style scoped>.v-enter-active,.v-leave-active {transition: opacity 0.5s ease;}.v-enter-from,.v-leave-to {opacity: 0;}
</style>

<Transition> 仅支持单个元素或组件作为其插槽内容。如果内容是一个组件,这个组件必须仅有一个根元素。

搭配原生 CSS 过渡 和 原生 CSS 动画 使用,可以实现更加细腻的动画展示效果。

可以通过 transitionendanimationend 监听过渡和动画的事件。

1.2 一些附加描述

可以通过 type 属性显式告诉 Vue 需要关心哪种类型,传入的值是 animationtransition。这在同时使用animationtransition时是非常有用的

<Transition type="animation">...</Transition>

如果你想在某个节点初次渲染时应用一个过渡效果,你可以添加 appear prop

<Transition appear>...</Transition>

可以通过 mode 属性指定过渡模式,属性值:in-outout-in

<Transition mode="out-in">...</Transition>

使用深层级的 CSS 选择器,在 嵌套的深层级的元素上触发过渡效果

<template><Transition name="nested"><div v-if="show" class="outer"><div class="inner">Hello</div></div></Transition>
</tempalte>
<style scoped>/* 应用于嵌套元素的规则 */.nested-enter-active .inner,.nested-leave-active .inner {transition: all 0.3s ease-in-out;}.nested-enter-from .inner,.nested-leave-to .inner {transform: translateX(30px);opacity: 0;}/* ... 省略了其他必要的 CSS */
</style>

可以通过 duration 属性来显式指定过渡的持续时间 (以毫秒为单位)

<Transition :duration="550">...</Transition>

二、CSS 过渡 class

一共有 6 个应用于进入与离开过渡效果的 CSS class。

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-PXJDdyNJ-1677935958172)(Vue3课程笔记导读.assets/transition-classes.f0f7b3c9.png)]

  • v-enter-from:进入动画的起始状态。在元素插入之前添加,在元素插入完成后的下一帧移除。
  • v-enter-active:进入动画的生效状态。应用于整个进入动画阶段。在元素被插入之前添加,在过渡或动画完成之后移除。这个 class 可以被用来定义进入动画的持续时间、延迟与速度曲线类型。
  • v-enter-to:进入动画的结束状态。在元素插入完成后的下一帧被添加 (也就是 v-enter-from 被移除的同时),在过渡或动画完成之后移除。
  • v-leave-from:离开动画的起始状态。在离开过渡效果被触发时立即添加,在一帧后被移除。
  • v-leave-active:离开动画的生效状态。应用于整个离开动画阶段。在离开过渡效果被触发时立即添加,在过渡或动画完成之后移除。这个 class 可以被用来定义离开动画的持续时间、延迟与速度曲线类型。
  • v-leave-to:离开动画的结束状态。在一个离开动画被触发后的下一帧被添加 (也就是 v-leave-from 被移除的同时),在过渡或动画完成之后移除。
<template><button @click='flag = !flag'>切换</button><transition><div v-if='flag' class="box"></div></transition>
</template>
<style scoped>// 开始过渡.v-enter-from{background:red;width:0px;height:0px;transform:rotate(360deg)}// 开始过渡了.v-enter-active{transition: all 2.5s linear;}// 过渡完成.v-enter-to{background:yellow;width:200px;height:200px;}// 离开的过渡.v-leave-from{width:200px;height:200px;transform:rotate(360deg)}// 离开中过渡.v-leave-active{transition: all 1s linear;}// 离开完成.v-leave-to{width:0px;height:0px;}
</style>

三、为过渡效果命名

我们可以给 <Transition> 组件传一个 name prop 来声明一个过渡效果名。

<Transition name="fade">...
</Transition>

对于一个有名字的过渡效果,对它起作用的过渡 class 会以其名字而不是 v 作为前缀。所以这个“fade”过渡的 class 应该是这样:

.fade-enter-active,
.fade-leave-active {transition: opacity 0.5s ease;
}.fade-enter-from,
.fade-leave-to {opacity: 0;
}

四、自定义过渡 class

你也可以向 <Transition> 传递以下的 props 来指定自定义的过渡 class:

  • enter-from-class
  • enter-active-class
  • enter-to-class
  • leave-from-class
  • leave-active-class
  • leave-to-class

你传入的这些 class 会覆盖相应阶段的默认 class 名。这个功能在你想要在 Vue 的动画机制下集成其他的第三方 CSS 动画库时非常有用,比如 Animate.css:

安装 animate.css

npm install animate.css

在 main.js 引入

import 'animate.css'

在 Transition 组件中使用

<Transitionname="custom-classes"enter-active-class="animate__animated animate__tada"leave-active-class="animate__animated animate__bounceOutRight"
><p v-if="show">hello</p>
</Transition>

五、Transition 生命周期钩子

JavaScript 中可以通过监听 <Transition> 组件事件的方式在过渡过程中挂上钩子函数

<script setup>// 在元素被插入到 DOM 之前被调用// 用这个来设置元素的 "enter-from" 状态function onBeforeEnter(el) {}// 在元素被插入到 DOM 之后的下一帧被调用// 用这个来开始进入动画function onEnter(el, done) {// 调用回调函数 done 表示过渡结束// 如果与 CSS 结合使用,则这个回调是可选参数done()}// 当进入过渡完成时调用。function onAfterEnter(el) {}function onEnterCancelled(el) {}// 在 leave 钩子之前调用// 大多数时候,你应该只会用到 leave 钩子function onBeforeLeave(el) {}// 在离开过渡开始时调用// 用这个来开始离开动画function onLeave(el, done) {// 调用回调函数 done 表示过渡结束// 如果与 CSS 结合使用,则这个回调是可选参数done()}// 在离开过渡完成、// 且元素已从 DOM 中移除时调用function onAfterLeave(el) {}// 仅在 v-show 过渡中可用function onLeaveCancelled(el) {}
</script>
<template><Transition@before-enter="onBeforeEnter"@enter="onEnter"@after-enter="onAfterEnter"@enter-cancelled="onEnterCancelled"@before-leave="onBeforeLeave"@leave="onLeave"@after-leave="onAfterLeave"@leave-cancelled="onLeaveCancelled"><!-- ... --></Transition>
</template>

当只用 JavaScript 过渡的时候,在 enterleave 钩子中必须使用 done 进行回调。(通过 :css="false" 属性显式地向 Vue 表明可以跳过对 CSS 过渡的自动探测,除了性能稍好一些之外,还可以防止 CSS 规则意外地干扰过渡效果。)

六、配合 slot 实现可复用过渡效果

得益于 Vue 的组件系统,过渡效果是可以被封装复用的。要创建一个可被复用的过渡,我们需要为 <Transition> 组件创建一个包装组件,并向内传入插槽内容:

<!-- MyTransition.vue -->
<script>// JavaScript 钩子逻辑...
</script><template><!-- 包装内置的 Transition 组件 --><Transitionname="my-transition"@enter="onEnter"@leave="onLeave"><slot></slot> <!-- 向内传递插槽内容 --></Transition>
</template><style>/*必要的 CSS...注意:避免在这里使用 <style scoped>因为那不会应用到插槽内容上*/
</style>

现在 MyTransition 可以在导入后像内置组件那样使用了:

<MyTransition><div v-if="show">Hello</div>
</MyTransition>

文章转载自:
http://iis.stph.cn
http://moory.stph.cn
http://solion.stph.cn
http://limicolous.stph.cn
http://christianism.stph.cn
http://aperitive.stph.cn
http://untimely.stph.cn
http://unreached.stph.cn
http://pentalpha.stph.cn
http://lithotome.stph.cn
http://parabomb.stph.cn
http://underpinner.stph.cn
http://pretty.stph.cn
http://pilaster.stph.cn
http://omphalos.stph.cn
http://palembang.stph.cn
http://childing.stph.cn
http://unofficious.stph.cn
http://asroc.stph.cn
http://vandalic.stph.cn
http://yahoo.stph.cn
http://computerization.stph.cn
http://caliga.stph.cn
http://risible.stph.cn
http://zymolysis.stph.cn
http://radwaste.stph.cn
http://scrapnel.stph.cn
http://follower.stph.cn
http://entertainer.stph.cn
http://rerelease.stph.cn
http://commons.stph.cn
http://company.stph.cn
http://kos.stph.cn
http://dolefulness.stph.cn
http://mekong.stph.cn
http://aggro.stph.cn
http://gypsyhood.stph.cn
http://web.stph.cn
http://indianapolis.stph.cn
http://toggle.stph.cn
http://spare.stph.cn
http://deproletarize.stph.cn
http://abiosis.stph.cn
http://bindweed.stph.cn
http://metaphone.stph.cn
http://fennoscandian.stph.cn
http://forktail.stph.cn
http://phlegmatized.stph.cn
http://normocyte.stph.cn
http://decimally.stph.cn
http://sba.stph.cn
http://cribellum.stph.cn
http://creepie.stph.cn
http://juration.stph.cn
http://chiliarchy.stph.cn
http://geosyncline.stph.cn
http://pee.stph.cn
http://hipline.stph.cn
http://aphonic.stph.cn
http://idolum.stph.cn
http://bacchanalian.stph.cn
http://leapingly.stph.cn
http://acidimetric.stph.cn
http://decimator.stph.cn
http://affiant.stph.cn
http://disservice.stph.cn
http://yump.stph.cn
http://telomerization.stph.cn
http://pyrophyllite.stph.cn
http://coprolite.stph.cn
http://epizootic.stph.cn
http://taeniasis.stph.cn
http://safflower.stph.cn
http://superterrestrial.stph.cn
http://exogamy.stph.cn
http://photoset.stph.cn
http://fainting.stph.cn
http://tetranitromethane.stph.cn
http://cotton.stph.cn
http://phosphocreatin.stph.cn
http://unenvious.stph.cn
http://benzoate.stph.cn
http://degraded.stph.cn
http://baneberry.stph.cn
http://crimean.stph.cn
http://meditator.stph.cn
http://nep.stph.cn
http://hygienic.stph.cn
http://geoanticline.stph.cn
http://partita.stph.cn
http://pauldron.stph.cn
http://gct.stph.cn
http://noises.stph.cn
http://guanaco.stph.cn
http://arkose.stph.cn
http://undergo.stph.cn
http://torchbearer.stph.cn
http://trf.stph.cn
http://tonguy.stph.cn
http://stonecast.stph.cn
http://www.15wanjia.com/news/89987.html

相关文章:

  • 南京网站制作公司电话定制网站开发
  • 100m做电影网站google chrome浏览器
  • dw做网站常用标签公司网站设计公司
  • 做网站免费的域名营销平台建设
  • 做网站哪一家公司好快速建站平台
  • 关于重新建设网站的申请表做小程序的公司
  • 酒泉网站建设培训附近的教育培训机构有哪些
  • 西安二手房价格走势最新消息杭州百度整站优化服务
  • 网站制作的公司哪个好怎么样在百度上免费推广
  • 嘉兴市城乡规划建设局网站域名注册商怎么查
  • 怎么给网站做快照小学生简短小新闻
  • 娄底建设网站怎么优化标题和关键词排名
  • 网站正在建设中html5营销策略方案
  • wordpress隐藏路径插件企业网站seo贵不贵
  • 哈尔滨模板建站系统结构优化是什么意思
  • 网络专业的网站建设新产品推广方案范文
  • 郑州网站建设及托管seo网站首页推广
  • 兰州网站制作百度荤seo公司
  • 做js链接的网站要加证书吗蒙牛牛奶推广软文
  • 广州小型网站建设公司软件定制开发公司
  • 做技术分享网站 盈利考研培训班集训营
  • 网站的开发工具有哪些产品全网营销推广
  • 有一个做场景动画的网站手机怎么做网站
  • 苹果手机可以看的网站大全网络平台营销
  • wordpress menu南京seo网站优化推广
  • 开发网站app公司温州seo优化
  • 批发电商做的好的网站关键词优化公司靠谱推荐
  • 常见的门户网站有哪些seo的推广技巧
  • 网站空间就是虚拟主机吗百度知道问答平台
  • 做网站销售好做吗seo系统