All Projects → CommanderXL → xRoute

CommanderXL / xRoute

Licence: other
一个小型的前端路由库✈️

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects
HTML
75241 projects

Projects that are alternatives of or similar to xRoute

React
🔼 UI-Router for React
Stars: ✭ 386 (+972.22%)
Mutual labels:  spa, router
Webvr Webpack Boilerplate
A webvr multi-scenes Single-page application for three.js, webpack
Stars: ✭ 47 (+30.56%)
Mutual labels:  spa, router
React Static Complete Website
A complete website built using React JS, With SEO, Code Splitting, Pre-rendering, gzip and more.
Stars: ✭ 16 (-55.56%)
Mutual labels:  spa, webpack2
Angular
UI-Router for Angular: State-based routing for Angular (v2+)
Stars: ✭ 287 (+697.22%)
Mutual labels:  spa, router
Universal Router
A simple middleware-style router for isomorphic JavaScript web apps
Stars: ✭ 1,598 (+4338.89%)
Mutual labels:  spa, router
Miox
Modern infrastructure of complex SPA
Stars: ✭ 374 (+938.89%)
Mutual labels:  spa, router
Vanilla Ui Router
Simple vanilla JavaScript router
Stars: ✭ 42 (+16.67%)
Mutual labels:  spa, router
Abstract State Router
Like ui-router, but without all the Angular. The best way to structure a single-page webapp.
Stars: ✭ 288 (+700%)
Mutual labels:  spa, router
Sme Router
A lightweight router lib that implement with express route style
Stars: ✭ 112 (+211.11%)
Mutual labels:  spa, router
Routegen
Define your API and SPA routes in one place. Use them anywhere. Only 1.3kb.
Stars: ✭ 86 (+138.89%)
Mutual labels:  spa, router
Frontexpress
An Express.js-Style router for the front-end
Stars: ✭ 263 (+630.56%)
Mutual labels:  spa, router
Redux Tower
Saga powered routing engine for Redux app.
Stars: ✭ 155 (+330.56%)
Mutual labels:  spa, router
Jsoo router
A small router to write easily single-page-app in Js_of_ocaml
Stars: ✭ 24 (-33.33%)
Mutual labels:  spa, router
Preact Redux Isomorphic
preact-redux-isomorphic PWA SPA SSR best practices and libraries in under 80kB page size (for live demo click the link below)
Stars: ✭ 85 (+136.11%)
Mutual labels:  spa, webpack2
React Resource Router
Configuration driven routing solution for React SPAs that manages route matching, data fetching and progressive rendering
Stars: ✭ 136 (+277.78%)
Mutual labels:  spa, router
Productivity Frontend
Productivity Application - Kanban Style Productivity Management Application with Customizable Boards, Lists and Cards to Make You More Productive.
Stars: ✭ 234 (+550%)
Mutual labels:  spa, webpack2
summary1
个人总结 持续更新 欢迎提出各种issues
Stars: ✭ 13 (-63.89%)
Mutual labels:  webpack2
okwolo
light javascript framework to build web applications
Stars: ✭ 19 (-47.22%)
Mutual labels:  router
http-server-router
A router for Amp's HTTP Server.
Stars: ✭ 28 (-22.22%)
Mutual labels:  router
cloudMusic
(移动端)Vue2.0+Nodejs网易云音乐,网易云音乐api强力驱动,高音质破解(持续更新中)
Stars: ✭ 14 (-61.11%)
Mutual labels:  webpack2

简述

一个小型的SPA框架.无依赖第三方的小型路由,搭配webpack作为构建工具,主要利用webpackcode spilt及异步加载功能。

路由

高级浏览器使用H5 API,低级浏览器使用hash

  html5Mode:
  www.example.com/page1
  www.example.com/page2

  hashMode:
  www.example.com/#/page1
  www.example.com/#/page2

Router所管理的页面生命周期

一共有5个阶段:

  • beforeEnter
  • pageInit
  • viewInit
  • viewDestory
  • beforeLeave

路由配置

  const Router = new Route();

  Router
    .addRoute({
      path: 'a',
      viewBox: '',  // 容器锚点
      template: '', // 页面模板
      animate: 'slideInRight', //转场动画
      pageInit() {  // 异步加载ctrl,同时将ctrl挂载到route
        const Controller = require('modules/path1/controller');
        Router.registerCtrl('path1', new Controller(this.viewBox));
      },
      beforeEnter() {
        
      },
      beforeLeave() {

      }
    })
    .addRoute({
      path: 'b',
      viewBox: '',  
      template: '',
      animate: 'slideInRight', //转场动画 
      pageInit() { 
        const Controller = require('modules/path2/controller');
        Router.registerCtrl('path2', new Controller(this.viewBox));
      },
      beforeEnter() {

      },
      beforeLeave() {

      }
    })

页面逻辑

  export default class PageModel {
    constructor(container) {  
      //页面容器,获取dom通过这个容器root DOM来获取
      this.container = document.querySelector(container);
    }
    setDomMap() {
      let barDom = this.container.querySelector('.barDom');
    }
    viewInit() {

    }
    viewDestory() {
      
    }
    init() {
      this.setDomMap();
      this.viewInit();
    }
  }

转场动画

  slideInRight
  slideInLeft
  fadeIn
  fadeOut
  zoomIn
  zoomOut

使用方法

  npm install
  npm run dev
  浏览器中打开localhost:3000/pages/register/
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].