How to use the san-router.router.add function in san-router

To help you get started, we’ve selected a few san-router examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ecomfe / santd / site / src / index.js View on Github external
attached() {
        const that = this;
        // 错误提示
        window.addEventListener('error', this.handleError.bind(this), false);

        // 添加路由
        router.add({
            rule: '/:type/:id',
            handler(e) {
                // console.log(e); // eslint-disable-line
            }
        });

        // 路由监听
        router.listen(e => {
            const query = e.query;
            if (e.path === '/') {
                that.handleRedirect({key: defaultPath});
                that.data.set('currentPath', defaultPath);
            }
            else {
                that.data.set('currentPath', e.path);
                document.getElementById('content').innerHTML = '';
github baidu / san / example / todos-store / src / main.js View on Github external
require('font-awesome/css/font-awesome.min.css')
require('./main.css')

// actions
import './todo/action'
import './category/action'

// route
import List from './todo/List'
import Form from './todo/Form'
import AddCategory from './category/Add'
import EditCategory from './category/Edit'

import {router} from 'san-router'

router.add({rule: '/', Component: List, target: '#app'});
router.add({rule: '/todos/category/:category', Component: List, target: '#app'});
router.add({rule: '/add', Component: Form, target: '#app'});
router.add({rule: '/edit/:id', Component: Form, target: '#app'});
router.add({rule: '/category/add', Component: AddCategory, target: '#app'});
router.add({rule: '/category/edit', Component: EditCategory, target: '#app'});

// start
router.start();
github baidu / san / example / todos-amd / src / app-perf.js View on Github external
define(function (require) {
    var List = require('./todo/List-perf');
    var Form = require('./todo/Form');
    var AddCategory = require('./category/Add');
    var EditCategory = require('./category/Edit');

    var router = require('san-router').router;
    router.add({rule: '/', Component: List, target: '#wrap'});
    router.add({rule: '/todos/category/:category', Component: List, target: '#wrap'});
    router.add({rule: '/add', Component: Form, target: '#wrap'});
    router.add({rule: '/edit/:id', Component: Form, target: '#wrap'});
    router.add({rule: '/category/add', Component: AddCategory, target: '#wrap'});
    router.add({rule: '/category/edit', Component: EditCategory, target: '#wrap'});

    return {
        init: function () {
            router.start();
        }
    };

});
github PaddlePaddle / VisualDL / frontend / deprecated / graph / index.js View on Github external
import {router} from 'san-router';

import Graph from './Graph';

router.add({
  target: '#content',
  rule: '/graphs',
  Component: Graph,
});
github PaddlePaddle / VisualDL / frontend / deprecated / histogram / index.js View on Github external
import {router} from 'san-router';

import Histogram from './Histogram';

router.add({
  target: '#content',
  rule: '/histograms',
  Component: Histogram,
});
github PaddlePaddle / VisualDL / frontend / deprecated / home / index.js View on Github external
import {router} from 'san-router';
import HomePage from './Home';

router.add({
    target: '#content',
    rule: '/welcome',
    Component: HomePage
});
github PaddlePaddle / VisualDL / frontend / deprecated / scalars / index.js View on Github external
import {router} from 'san-router';

import Scalar from './Scalars';

router.add({
  target: '#content',
  rule: '/',
  Component: Scalar,
});

router.add({
  target: '#content',
  rule: '/scalars',
  Component: Scalar,
});
github ecomfe / san-realworld-app / src / index.js View on Github external
axios.defaults.validateStatus = function (status) {
        return status >= 200 && status < 500;
    };

    (new Header).attach(document.getElementById('header'));
    (new Footer).attach(document.getElementById('footer'));

    router.listen(e => {
        store.dispatch(ActionTypes.ERRORS_CLEAR);
        store.dispatch(UserActionTypes.GET);
    });

    router.add({rule: '/', Component: Home});
    router.add({rule: '/tag/:tag', Component: Home});
    router.add({rule: '/my-feed', Component: Home});
    router.add({rule: '/login', Component: Login});
    router.add({rule: '/register', Component: Register});
    router.add({rule: '/settings', Component: Setting});
    router.add({rule: '/profile/:user', Component: ProfileMy});
    router.add({rule: '/profile/:user/favorites', Component: ProfileFavorited});
    router.add({rule: '/editor', Component: ArticleEdit});
    router.add({rule: '/editor/:slug', Component: ArticleEdit});
    router.add({rule: '/article/:slug', Component: ArticleView});

    
    router.start();
}
github PaddlePaddle / VisualDL / frontend / deprecated / images / index.js View on Github external
import {router} from 'san-router';

import Images from './Images';

router.add({
  target: '#content',
  rule: '/images',
  Component: Images,
});
github PaddlePaddle / VisualDL / frontend / src / audio / index.js View on Github external
import {router} from 'san-router';

import Audio from './Audio';

router.add({
  target: '#content',
  rule: '/audio',
  Component: Audio,
});

san-router

Router for San

MIT
Latest version published 1 year ago

Package Health Score

52 / 100
Full package analysis

Similar packages