file-type

Vue2-animate实现Vue.js 2.0动画过渡效果

下载需积分: 50 | 125KB | 更新于2025-02-20 | 44 浏览量 | 0 下载量 举报 收藏
download 立即下载
### 知识点详解 #### 1. Vue.js 2.0端口概念 在讨论`vue2-animate`之前,有必要解释一下“端口”这一概念。在软件开发中,一个端口通常指的是一个程序或库被改编或移植到另一个平台的过程。在这个案例中,`vue2-animate`是将流行CSS动画库`Animate.css`适配到Vue.js 2.0的过程。对于前端开发者而言,这意味着可以利用Vue.js框架的特性来使用Animate.css提供的动画效果。 #### 2. Animate.css库介绍 `Animate.css`是一个跨浏览器的CSS3动画库,它通过预定义的CSS类来实现各种动画效果。它支持简单的动画触发和复杂动画序列,为开发者提供了一种方便的方式,来给网页元素添加生动的动画效果。 #### 3. Vue.js 2.0与Vue.js 3.0的不同 `vue2-animate`支持Vue.js的两个主要版本,即Vue.js 2.0和Vue.js 3.0。Vue.js 3.0是Vue.js的最新版本,它在性能、功能和API上都进行了一系列的改进。比如,Vue.js 3.0引入了Composition API,提供了更好的TypeScript支持和更多的响应式系统优化。尽管两个版本的功能有一些差异,但是`vue2-animate`都能兼容使用,为不同版本的Vue.js开发者提供便利。 #### 4. 跨浏览器CSS3动画 由于`vue2-animate`是基于`Animate.css`,它支持各种现代浏览器,通常包括Chrome、Firefox、Safari、Edge等主流浏览器。对于开发者来说,这意味着他们可以更专注地编写功能代码,而不用担心跨浏览器兼容性问题。 #### 5. Vue的内置转换(Transition)系统 Vue.js内置了一个强大的转换系统,用于在元素插入和删除时提供过渡或动画效果。这个系统是Vue响应式数据更新的一部分,能够自动检测DOM的变化并应用相应的动画效果。`vue2-animate`是与这个转换系统紧密结合的,它提供了现成的动画类集合,可以直接应用于Vue组件或元素。 #### 6. 安装方法 要使用`vue2-animate`,需要按照一定的方式进行安装,以便在项目中引入该库: - **通过npm安装:** ```shell npm install vue2-animate --save ``` - **通过yarn安装:** ```shell yarn add vue2-animate ``` - **通过CDN引入:** 在HTML文件中通过`<link>`标签引入对应的CSS文件,或者在JavaScript中全局引入Vue和`vue2-animate`。 ```html <!-- 包括样式表 --> <head> <link rel="stylesheet" href="vue2-animate.min.css"> </head> ``` ```javascript // 通过CDN在JavaScript中引入 <script src="https://unpkg.com/vue2-animate/dist/vue2-animate.min.js"></script> ``` #### 7. SCSS版本 `vue2-animate`不仅提供了预编译的CSS版本,也支持SCSS版本。这意味着,如果你的项目使用SCSS作为样式表预处理器,你可以直接通过SCSS方式引用`Animate.css`,从而提供更高的灵活性和可定制性。 #### 8. 信用与贡献 文档中提到,虽然原始作者是为Vue 1.x版本创建的`vue2-animate`,而SCSS版本是由另一个作者创建的。但当前的维护者是负责当前版本的更新与维护。这表明开源项目中,社区的贡献非常重要,并且需要鼓励开发者的反馈和贡献。 #### 9. Vue.js相关技术标签解析 - **Vue.js**: 一个渐进式的JavaScript框架,用于构建用户界面。 - **animation**: 动画是使元素发生变化的过程,CSS提供了强大的动画能力。 - **transition**: Vue.js内置的一个指令,用于过渡效果的实现。 - **vue-transition**: 是Vue.js中用于创建过渡动画效果的组件。 - **Vue.jsSCSS**: 表示使用SCSS预处理器编写的Vue.js样式。 #### 10. 关于vue2-animate-master `vue2-animate-master`文件夹的名称暗示这是`vue2-animate`项目的主版本,很可能包含所有源代码、文档和构建脚本。对于开发者来说,如果想要查看源代码或贡献代码,这会是他们需要访问的资源。 总结起来,`vue2-animate`允许开发者通过简单地引用一个CSS库,来为Vue.js应用提供美观的过渡效果和动画。这一工具大大简化了在Vue.js项目中实现复杂动画效果的过程,使得Web开发者能够专注于核心功能的开发,同时不必担心动画效果的实现细节。

相关推荐

filetype

RTSPWebRTCPlayer.vue:113 POST http://127.0.0.1:8083/stream/26ac931a-7d23-4a40-b9e0-0ddfda2a67e7/channel/0/webrtc 400 (Bad Request) dispatchXhrRequest @ xhr.js:195 xhr @ xhr.js:15 dispatchRequest @ dispatchRequest.js:51 _request @ Axios.js:173 request @ Axios.js:40 httpMethod @ Axios.js:212 wrap @ bind.js:5 startPlay @ RTSPWebRTCPlayer.vue:113 await in startPlay(异步) (匿名) @ RTSPWebRTCPlayer.vue:149 (匿名) @ runtime-core.esm-bundler.js:2757 callWithErrorHandling @ runtime-core.esm-bundler.js:199 callWithAsyncErrorHandling @ runtime-core.esm-bundler.js:206 hook.__weh.hook.__weh @ runtime-core.esm-bundler.js:2737 flushPostFlushCbs @ runtime-core.esm-bundler.js:385 flushJobs @ runtime-core.esm-bundler.js:427 Promise.then(异步) queueFlush @ runtime-core.esm-bundler.js:322 queueJob @ runtime-core.esm-bundler.js:317 effect2.scheduler @ runtime-core.esm-bundler.js:5388 trigger @ reactivity.esm-bundler.js:250 endBatch @ reactivity.esm-bundler.js:308 notify @ reactivity.esm-bundler.js:594 trigger @ reactivity.esm-bundler.js:568 set value @ reactivity.esm-bundler.js:1510 (匿名) @ index.vue:1750 checkCollision @ index.vue:1743 animate @ index.vue:1577 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 requestAnimationFrame(异步) animate @ index.vue:1561 显示另外 21 个框架 收起 RTSPWebRTCPlayer.vue:144 WebRTC连接失败: AxiosError {message: 'Request failed with status code 400', name: 'AxiosError', code: 'ERR_BAD_REQUEST', config: {…}, request: XMLHttpRequest, …}

filetype

<template>
<logo-svg class="logo-svg" />
<router-link :to="{name:'home'}" class="logo-text"> {{appStore.title}} </router-link>
<template v-for="m in menus"> {{m.text}} <router-link v-else :to="{name: m.code}" @click="play" class="menu-item nav-ab t" :class="m.code"> {{m.text}} </router-link> </template>
欢迎你,超级管理员
<el-button size="small" type="primary" plain class="is-square" icon="Sunny" @click="appStore.toggleTheme()"></el-button> <el-button size="small" type="primary" plain class="is-square" icon="FullScreen" @click="toggleFullscreen()"></el-button> <el-button size="small" type="primary" plain class="is-square" icon="MoreFilled"></el-button> <el-button size="small" type="danger" plain>退出</el-button>
</template> <script setup lang="ts"> import _ from "lodash" import {computed, onMounted, ref, onUnmounted} from "vue"; import {useAppStore} from "@/services/store/app"; import {Howl} from 'howler'; import menuSound from "@/assets/medias/menu.mp3" import {useNow, useDateFormat, useDark} from '@vueuse/core' import animate1Image from "./images/animate-1.png" import animate2Image from "./images/animate-2.png" import logoSvg from "@/assets/images/logo.svg" const appStore = useAppStore(); const now = useNow(); const nowTime = ref('') const timer = ref() const isDark = useDark(); //region sound var sound = new Howl({ src: [menuSound], volume: .4 }); const play = () => { sound.play(); }; //endregion const menus = [ {code:'home', text:'首页', icon:'mdi-home'}, {code:'network', text:'网络', icon:'mdi-lan'}, {code:'transfer', text:'数据', icon:'mdi-transfer'}/*, {code:'stat', text:'检索统计', icon:'mdi-chart-bar-stacked', href: headerQueryMenuUrl}, {code:'manage', text:'后台管理', icon:'mdi-monitor-dashboard', href:headerManageMenuUrl}*/ ]; import {usePageAnimate} from "@/services/hook/usePageAnimate"; import axios from "axios"; usePageAnimate("nav-ab"); onMounted(() => { }); onUnmounted(()=> { }) import { useFullscreen } from '@vueuse/core' import {headerManageMenuUrl, headerQueryMenuUrl} from "@/services/config"; const { isFullscreen, enter, exit, toggle: toggleFullscreen } = useFullscreen() </script> <style lang="scss" scoped> @use "sass:math"; @import "@/assets/css/_var"; $padding: 36px; .nav { position:absolute; left:$padding;right:$padding;top:$padding; z-index:10; height:80px; backdrop-filter: blur(3px); //box-shadow: 0 1px 10px rgba(0,0,0,.3) //background-color: rgba(red,.5); } .header-bg { //height: 90px; width:100%; //background: url(./images/header-bg.png) no-repeat bottom center; //background-size: contain; position: absolute; z-index:0; top:0;left:0;right:0;bottom:0; border-top: transparent solid 6px; border-bottom: transparent solid 1px; background: rgba($-primary-color, 0.3); border-top-color:$-primary-color; border-bottom-color: $-primary-color; box-shadow: 0 0 6px #035f71; &:after { content:""; position: absolute;top:0;bottom:0;left:0;right:0; //background: linear-gradient(45deg , rgba($-primary-color , .5) 60%, $-primary-color); } } .right-side { position: relative; } .logo-con { display: flex; align-items: center; justify-content: center; } .logo-border { //background:rgba(255,255,255,.1); padding:0 25px;display:flex;align-items:center; height:100%; position:relative;z-index:1; border-top:transparent solid 6px; border-bottom:transparent solid 6px; box-shadow: 1px 0 10px rgba(0,0,0,.2); border-color: rgba($-primary-color, 1);; } .logo-svg { width:60px;margin-left1:10px; //filter: drop-shadow( 0px 0px 6px rgba(#bcffff, .3)); //fill: #00c8e1; :deep { path {fill:#253223} path.lightning { fill:#ffcc00; stroke-width: 0; } //.circle-middle { // fill: #ffcc00; //} .dot {fill:#ffcc00;} .circle-bg {fill:transparent} } } .logo-text { padding-left:20px; font-family: shuhei;font-size:42px; margin-top:3px; text-shadow1: 5px 5px 1px rgba(255,255,255,.1); filter: drop-shadow( 1px 1px 2px #253223); background-image: -webkit-linear-gradient(90deg, rgb(245, 255, 250) , $-primary-color ); //background-image: linear-gradient(180deg,#fff,#2af1f8); -webkit-background-clip: text; -webkit-text-fill-color: transparent; } .menu-con { display: flex; flex:1; justify-content: center; position:relative;z-index:1; margin-top:6px; } .menu-item { display: flex; align-items: center;justify-content: center; border:rgba(#253223,.9) solid 1px; background: rgba($-primary-color,.4); color:rgba(#253223, .8); border-radius:2px; width:150px;height:44px; margin:0 15px; background-size:cover; text-align:center; font-size:20px; font-family: fzzzh; font-weight: normal; letter-spacing: 5px; transition: all .3s; span.mdi {opacity: .9} &:after, &:before { transition: all .3s; content:''; position: absolute; width:3px;height:24px; background: rgba(#253223,.6) } &:before {left:0;} &:after { right:0; } &:hover { border-color:#253223; color:#253223; background: rgba(#fff, .8); &:after, &:before { height:28px; background: rgba(#253223,.9) } &:after {right:3px} &:before {left:3px} } &.router-link-active { span.mdi {opacity: 1} color: $-primary-color; border-width:2px; border-radius:4px; border-color:$-primary-color; background: rgba(14, 31, 14,.9); font-weight:bold; box-shadow: 0 0 8px #253223; &:after, &:before { width:4px; background: rgba($-primary-color,.8) } } &.job, &.live, &.vehicle{ text-decoration: line-through; } } .animate-blocks { width: 55px; height: 25px; left: 662px; top: 74px; position: absolute; visibility: visible; pointer-events: none; transition: transform 600ms; display: flex; align-items: center; justify-content: space-evenly; } .animate-block-item { width:8px;height:10px; background: linear-gradient(to right , rgba(120, 255, 255, .8) , transparent); transform: skewX(-40deg); border-radius:1px; } .animate-1-con { position: absolute; pointer-events: none; left: 399px; top: 0; width: 120px; height: 100%; opacity:.3; } .animate-1-img { width:100%;height:100%; border-radius: unset; cursor: pointer; pointer-events: none; animation-name: animate-1; animation-iteration-count: infinite; animation-timing-function: linear; animation-duration: 5s; animation-delay: 0s; -webkit-user-drag: none; filter: none; } @keyframes animate-1 { 0% { opacity: 0; transform: none; } 15% { opacity: 0.75; transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scaleX(1) scaleY(1) translate3d(150px, 0px, 0px); } 30% { opacity: 1; transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scaleX(1) scaleY(1) translate3d(300px, 0px, 0px); } 45% { opacity: 0.75; transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scaleX(1) scaleY(1) translate3d(450px, 0px, 0px); } 60% { opacity: 0; transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scaleX(1) scaleY(1) translate3d(600px, 0px, 0px); } 100% { opacity: 0; transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scaleX(1) scaleY(1) translate3d(600px, 0px, 0px); } } .animate-2-con { position: absolute; pointer-events: none; left: 646px; bottom: 0; width: 120px; height: 60%; opacity:.3; } .animate-2-img { width:100%;height:100%; border-radius: unset; cursor: pointer; pointer-events: none; animation-name: animate-2; animation-iteration-count: infinite; animation-timing-function: linear; animation-duration: 4s; animation-delay: 0s; -webkit-user-drag: none; filter: none; } @keyframes animate-2 { 0% { opacity: 0; transform: none; } 50% { opacity: .78; transform: translateX(450px); } 100% { opacity: 0; transform: translateX(900px); } } $star-width: math.div(1120px, 1.5); $star-height: math.div(660px, 1.5); .star { position:absolute;top:-113px;left:-10px; width:$star-width;height:$star-height; background: url(./images/star.png) no-repeat bottom center; background-size: cover; animation-name: star-animate; animation-iteration-count: infinite; animation-timing-function: linear; animation-duration: 10s; animation-delay: 10s; -webkit-user-drag: none; //filter: brightness(150%); } @keyframes star-animate { 0% { opacity: 1; } 50% { opacity: .5; } 100% { opacity: 1; } } div.nav.dark { .header-bg { border-top-color:rgb(71, 128, 76); border-bottom-color:rgba(6, 253, 253, .15); background: rgba($-primary-color, 0.3); //background-color: rgba(106, 211, 137, 0.12); &:after { background: linear-gradient(-45deg , rgba(0,0,0,.4), transparent); } } .logo-border { border-color: rgb(71, 128, 76); } .logo-text { background-image: -webkit-linear-gradient(90deg, rgb(150, 248, 140) 0%, rgb(245, 255, 250) 90%); } .logo-svg { :deep { path {fill:rgba(113, 228, 102,.6)} path.lightning { fill:#ffcc00; stroke-width: 0; } //.dot {fill:rgba(#fff,.7);} .circle-bg {fill:transparent} } } $-menu-color: #71e466; //7cffff .menu-item { border:rgba($-menu-color,.3) solid 1px; background: rgba(0,0,0,.2); color:rgba($-menu-color, .5); &:after, &:before { background: rgba($-menu-color,.3) } &:hover { border-color:$-menu-color; color:$-menu-color; background: rgba($-menu-color, .1); &:after, &:before { background: rgba($-menu-color,.6) } } &.router-link-active { color: $-menu-color; border-color:$-menu-color; &:after, &:before { background: rgba($-menu-color,.8) } } } } </style>

filetype

优化依赖{ "name": "wusuo", "version": "1.0.0", "description": "A Vue.js project", "private": true, "scripts": { "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js", "start": "npm run dev", "build": "node build/build.js" }, "dependencies": { "@jiaminghi/data-view": "^2.10.0", "animate.css": "^4.1.1", "ant-design-vue": "^1.7.8", "axios": "^0.27.2", "d3": "^3.5.17", "dom-to-image": "^2.6.0", "echarts": "^5.3.3", "echarts-gl": "^2.0.9", "echarts-wordcloud": "^2.1.0", "element-china-area-data": "^4.2.0", "element-ui": "^2.15.13", "file-saver": "^2.0.5", "jquery": "^3.6.0", "less": "^4.1.3", "less-loader": "^11.1.0", "lib-flexible": "^0.3.2", "moment": "^2.29.4", "px2rem-loader": "^0.1.9", "qrcodejs2": "0.0.2", "qs": "^6.11.2", "quill-image-resize-module": "^3.0.0", "sm-crypto": "^0.3.13", "tippy.js": "^6.3.7", "vue": "^2.6.14", "vue-count-to": "^1.0.13", "vue-cropper": "^0.6.4", "vue-pdf": "^4.3.0", "vue-quill-editor": "^3.0.6", "vue-router": "^3.5.4", "vue-seamless-scroll": "^1.1.23", "vue-tree-to-table": "^1.0.4", "vue-video-player": "^5.0.1", "vuex": "^3.6.2" }, "devDependencies": { "@babel/core": "^7.27.1", "@babel/plugin-proposal-object-rest-spread": "^7.20.7", "@babel/preset-env": "^7.27.2", "autoprefixer": "^7.1.2", "babel-core": "^6.26.3", "babel-helper-vue-jsx-merge-props": "^2.0.3", "babel-loader": "^10.0.0", "babel-plugin-syntax-jsx": "^6.18.0", "babel-plugin-transform-runtime": "^6.23.0", "babel-plugin-transform-vue-jsx": "^3.7.0", "babel-preset-env": "^1.7.0", "babel-preset-stage-2": "^6.24.1", "chalk": "^2.4.2", "copy-webpack-plugin": "^4.6.0", "css-loader": "^0.28.11", "extract-text-webpack-plugin": "^3.0.2", "file-loader": "^1.1.11", "friendly-errors-webpack-plugin": "^1.7.0", "html-webpack-plugin": "^2.30.1", "node-notifier": "^5.4.5", "optimize-css-assets-webpack-plugin": "^3.2.1", "ora": "^3.4.0", "portfinder": "^1.0.28", "postcss-import": "^11.1.0", "postcss-loader": "^2.1.6", "postcss-url": "^7.3.2", "rimraf": "^2.7.1", "semver": "^5.7.1", "shelljs": "^0.8.5", "style-loader": "^0.23.1", "uglifyjs-webpack-plugin": "^1.3.0", "url-loader": "^0.6.2", "vue-loader": "^15.10.1", "vue-style-loader": "^4.1.3", "vue-template-compiler": "^2.6.14", "webpack": "^3.12.0", "webpack-bundle-analyzer": "^2.13.1", "webpack-dev-server": "^2.11.5", "webpack-merge": "^4.2.2" }, "engines": { "node": ">= 8.0.0", "npm": ">= 5.0.0" }, "browserslist": [ "> 1%", "last 2 versions", "not ie <= 8" ] }