Vueg----page-transition-plugin
为Vue应用添加页面间的转场特效( Page level transition plugin for vue-router)
Top Related Projects
🚦 The official router for Vue 2
This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
The Intuitive Vue Framework.
📝 Minimalistic Vue-powered static site generator
🛠️ webpack-based tooling for Vue.js Development
🎉 A curated list of awesome things related to Vue.js
Quick Overview
Vueg is a Vue.js plugin that provides smooth page transition effects for Single Page Applications (SPAs). It enhances the user experience by adding animated transitions between route changes, making navigation feel more fluid and engaging.
Pros
- Easy to integrate with existing Vue.js projects
- Customizable transition effects and durations
- Supports both Vue 2 and Vue 3
- Lightweight and performant
Cons
- Limited documentation and examples
- May not work well with complex page layouts
- Potential conflicts with other Vue plugins or custom transition implementations
- Requires careful consideration of performance impact on larger applications
Code Examples
- Basic installation and usage:
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import vueg from 'vueg'
import 'vueg/css/transition.css'
Vue.use(vueg, router)
new Vue({
router,
render: h => h(App)
}).$mount('#app')
- Customizing transition options:
Vue.use(vueg, router, {
duration: '0.6', // transition duration
enter: 'fadeInRight', // enter transition
leave: 'fadeOutLeft', // leave transition
shadow: false, // disable shadow effect
disable: false, // disable transitions globally
map: { // custom transition map
'/': 'fade',
'/about': 'slideLeft'
}
})
- Disabling transitions for specific routes:
{
path: '/no-transition',
component: NoTransitionComponent,
meta: {
vueg: false // disable transition for this route
}
}
Getting Started
-
Install the plugin:
npm install vueg
-
Import and use the plugin in your main.js file:
import Vue from 'vue' import App from './App.vue' import router from './router' import vueg from 'vueg' import 'vueg/css/transition.css' Vue.use(vueg, router) new Vue({ router, render: h => h(App) }).$mount('#app')
-
Add the
v-transition
attribute to your router-view component:<router-view v-transition></router-view>
-
Customize transitions as needed using the options object when initializing the plugin.
Competitor Comparisons
🚦 The official router for Vue 2
Pros of vue-router
- Official Vue.js routing solution, ensuring compatibility and long-term support
- Extensive documentation and large community support
- Advanced features like nested routes, dynamic route matching, and navigation guards
Cons of vue-router
- Lacks built-in page transition animations
- Requires more setup and configuration for complex routing scenarios
- May have a steeper learning curve for beginners
Code Comparison
vue-router:
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const router = new VueRouter({
routes: [
{ path: '/foo', component: Foo },
{ path: '/bar', component: Bar }
]
})
Vueg----page-transition-plugin:
import Vue from 'vue'
import vueg from 'vueg'
import 'vueg/css/transition.css'
Vue.use(vueg, router)
// In component template
<transition name="fade" mode="out-in">
<router-view></router-view>
</transition>
Summary
vue-router is the official routing solution for Vue.js, offering robust features and extensive community support. It excels in handling complex routing scenarios but requires more setup for animations. Vueg----page-transition-plugin focuses on providing smooth page transitions with minimal configuration, making it easier to implement animations but lacking some of the advanced routing features of vue-router. The choice between the two depends on the project's specific requirements for routing complexity and desired transition effects.
This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
Pros of Vue
- Comprehensive framework for building full-scale web applications
- Large ecosystem with extensive documentation and community support
- Flexible and scalable for projects of various sizes
Cons of Vue
- Steeper learning curve for beginners compared to Vueg
- Potentially overkill for simple projects or single-page transitions
- Requires more setup and configuration for basic functionality
Code Comparison
Vue (basic component):
<template>
<div>{{ message }}</div>
</template>
<script>
export default {
data() {
return {
message: 'Hello Vue!'
}
}
}
</script>
Vueg (page transition):
import Vue from 'vue'
import App from './App'
import router from './router'
import vueg from 'vueg'
import 'vueg/css/transition.css'
Vue.use(vueg, router)
new Vue({
el: '#app',
router,
render: h => h(App)
})
Summary
Vue is a full-featured framework suitable for complex applications, while Vueg focuses specifically on page transitions. Vue offers more flexibility and scalability but requires more setup. Vueg provides a simpler solution for adding smooth transitions between pages in Vue applications. The choice between them depends on the project's scope and requirements.
The Intuitive Vue Framework.
Pros of Nuxt
- Full-featured framework for building Vue.js applications with server-side rendering, static site generation, and more
- Extensive ecosystem with a wide range of modules and plugins
- Built-in routing, state management, and development tools
Cons of Nuxt
- Steeper learning curve due to its comprehensive nature
- Potentially heavier bundle size for smaller projects
- May introduce unnecessary complexity for simple single-page applications
Code Comparison
Vueg (page transition plugin):
import Vue from 'vue'
import App from './App'
import router from './router'
import vueg from 'vueg'
Vue.use(vueg, router)
Nuxt:
// nuxt.config.js
export default {
modules: ['@nuxtjs/axios'],
plugins: ['~/plugins/my-plugin.js'],
css: ['~/assets/css/main.css']
}
Summary
Vueg is a lightweight page transition plugin for Vue.js, focusing specifically on enhancing page transitions. Nuxt, on the other hand, is a comprehensive framework built on top of Vue.js, offering a wide range of features including server-side rendering, static site generation, and more. While Vueg is easier to integrate into existing Vue projects for quick transition enhancements, Nuxt provides a more robust foundation for building complex applications with additional built-in functionality and an extensive ecosystem.
📝 Minimalistic Vue-powered static site generator
Pros of VuePress
- Designed specifically for creating documentation sites, with built-in features for technical writing
- Offers a default theme optimized for documentation, reducing setup time
- Integrates seamlessly with Vue.js ecosystem and components
Cons of VuePress
- Less flexible for general-purpose page transitions compared to Vueg
- Requires more setup and configuration for non-documentation projects
- May have a steeper learning curve for developers unfamiliar with Vue.js
Code Comparison
Vueg (page transition):
import Vue from 'vue'
import App from './App'
import router from './router'
import vueg from 'vueg'
Vue.use(vueg, router)
VuePress (basic config):
module.exports = {
title: 'Hello VuePress',
description: 'Just playing around',
themeConfig: {
nav: [
{ text: 'Home', link: '/' },
{ text: 'Guide', link: '/guide/' },
]
}
}
Summary
Vueg is a lightweight plugin focused on page transitions for Vue.js applications, offering easy implementation of smooth transitions between routes. VuePress, on the other hand, is a full-fledged static site generator tailored for creating documentation websites. While Vueg provides more flexibility for custom page transitions, VuePress offers a comprehensive solution for documentation projects with built-in features and optimizations. The choice between the two depends on the specific needs of your project: custom page transitions (Vueg) or a documentation-focused site (VuePress).
🛠️ webpack-based tooling for Vue.js Development
Pros of vue-cli
- Comprehensive tooling for Vue.js development, including project scaffolding, build setup, and plugin management
- Official Vue.js tool with extensive documentation and community support
- Provides a full-featured development environment with hot-reloading, linting, and testing capabilities
Cons of vue-cli
- Larger learning curve for beginners due to its extensive features and configuration options
- May be overkill for small projects or simple page transitions
- Requires more setup time compared to lightweight plugins focused on specific functionalities
Code Comparison
vue-cli (project creation):
vue create my-project
cd my-project
npm run serve
Vueg (usage in a Vue component):
import vueg from 'vueg'
Vue.use(vueg, router)
// In component template
<transition name="fade" mode="out-in">
<router-view></router-view>
</transition>
While vue-cli provides a complete development environment for Vue.js projects, Vueg focuses specifically on page transitions. vue-cli offers more extensive features and customization options, making it suitable for larger projects. Vueg, on the other hand, is a lightweight plugin that can be easily integrated into existing Vue.js applications to add smooth page transitions with minimal setup.
🎉 A curated list of awesome things related to Vue.js
Pros of awesome-vue
- Comprehensive resource collection for Vue.js ecosystem
- Regularly updated with community contributions
- Covers a wide range of Vue-related topics and tools
Cons of awesome-vue
- Not a functional plugin or component
- Requires manual exploration to find specific resources
Code comparison
While a direct code comparison isn't relevant due to the nature of these repositories, here's a brief example of how they might be used:
awesome-vue:
## UI Components
- [Vue-multiselect](https://github.com/shentao/vue-multiselect) - Universal select/multiselect/tagging component for Vue.js.
- [vue-table-component](https://github.com/spatie/vue-table-component) - A straightforward Vue component to make force-filling tables a cinch.
Vueg:
import Vue from 'vue'
import App from './App'
import router from './router'
import vueg from 'vueg'
import 'vueg/css/transition-min.css'
Vue.use(vueg, router)
Summary
awesome-vue serves as a curated list of Vue.js resources, while Vueg is a specific page transition plugin. awesome-vue is more comprehensive but requires manual exploration, whereas Vueg provides immediate functionality for page transitions in Vue applications.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Exampleï¼
使ç¨æ¹æ³
å®è£ æ件
npm i vueg --save
å¼å ¥æ件
import vueg from 'vueg'
Vue.use(vueg, new Router(), Options) // ä¼ å
¥å®ä¾ååçrouter, Options为å¯éçæ件é
ç½®
æ件æ令
æ件注åäºå为v-transition
çæ令ï¼æ¥æ¶ä¸ä¸ªå¯éçOptionsåæ°ï¼å
¶å
å«çé
ç½®ä¼å
级é«äºå
¨å±é
ç½®ã
å¯ç¨æ件ï¼
为router-view
æ·»å v-transition
æ令åï¼è¯¥router-view
ä¸ææç页é¢é½å°å¯ç¨å¨ç»ï¼
<router-view v-transition></router-view>
æï¼ä¸ºtemplate
ä¸ç顶级æ ç¾æ·»å v-transition
æ令åï¼è¯¥é¡µé¢ç»ä»¶å°å¯ç¨å¨ç»ææ:
<template>
<page v-transition>
</page>
</template>
æ¯æNuxtã
Options
@property {number} duration å¨ç»æ¶é¿ãé»è®¤ä¸º0.3
@property {string} enter å
¥åºå¨ç»ï¼é»è®¤ä¸º'fadeInRight'
@property {string} leave 离åºå¨ç»ï¼é»è®¤ä¸º'fadeInLeft'
@property {boolean} disableAtSameDepths 深度ç¸åæ¶ç¦ç¨å¨ç»(éè¿urlä¸çåææ æ°é/å¤æ)ãé»è®¤ä¸ºfalse
@property {boolean} shadow æ¯å¦ä¸ºå
¥åºé¡µé¢æ·»å é´å½±ãé»è®¤ä¸ºtrue
@property {Object} map é»è®¤ä¸ºç©ºæ
åµä¸ï¼vuegæ ¹æ®url深度å¤ææ¯å
¥åºè¿æ¯ç¦»åºï¼ä½ææ¶å¯è½å¹¶ä¸æ¯ä½ æ³è¦çææï¼è¿æ¶ä½ å¯ä»¥ä½¿ç¨mapé项ã
ä¾åï¼`
map: {
'user-login':{
enter: ['user-register'],
leave: ['index'],
disable: ['user-login-sms']
}
}
`
ä¸é¢ä¾å表示ï¼ä»å为`user-login`çè·¯ç±å°å为`user-regiseter`çè·¯ç±è½¬åºï¼ä½¿ç¨å
¥åºå¨ç»ï¼åä¹å使ç¨ç¦»åºå¨ç»ã
ä»å为`user-login`çè·¯ç±å°å为`index`çè·¯ç±è½¬åºï¼ä½¿ç¨ç¦»åºå¨ç»ï¼åä¹å使ç¨å
¥åºå¨ç»ã
ä»å为`user-login`çè·¯ç±å°å为`user-login-sms`çè·¯ç±è½¬åºï¼ç¦ç¨è½¬åºå¨ç»ã
enter
ãleave
åæ°ä½¿ç¨çanimate.cssçå¨ç»ç±»åä½ä¸ºå¼ï¼æ¥çå
¨é¨å¯ç¨å¼ï¼è¯·è®¿é®ï¼https://daneden.github.io/animate.cssã
å¦å¤æ件èªå¸¦äºä¸ä¸ªå¯ç¨å¼ touchPoint
ï¼å¨ç»ææ为页é¢ä»è§¦æ¸(ç¹å»)ç¹æ¾å¤§å
¥åºã
Top Related Projects
🚦 The official router for Vue 2
This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
The Intuitive Vue Framework.
📝 Minimalistic Vue-powered static site generator
🛠️ webpack-based tooling for Vue.js Development
🎉 A curated list of awesome things related to Vue.js
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot