Giter Site home page Giter Site logo

vue-router-learn's Introduction

vue-router-learn

安装环境

npm install @vue/cli -g 
npm install -g @vue/cli-service-global

vue-router的工作流程:

`

  1. 用户导入vue-router的入口文件:index.js => import Router from "vue-router"; (1) 声明了VueRouter类

  2. 通过Vue.use安装使用Router插件 => 这一步是调用Router的install方法; (1) install方法全局混入了beforeCreate()生命周期函数; (2) 执行beforeCreate生命周期函数时,已经产生router实例了,调用router原型上的init方法

  3. new Router()实例,并将配置的路由表传入 => const router = new Router({}); (1) 创建路由映射表; (2) 根据不同的mode,new 不同的history实例;

  4. 导出router实例,并将router实例在new Vue()时传入;

  5. 渲染页面 (1) 从父级开始,依次创建,并执行每个组件的beforeCreate()方法,执行router的init方法,将_route定义在根实例上,并成为响应式数据; (2) 执行init(),先做一次路由跳转,

`

vue-router-learn's People

Contributors

jackzou888 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.