How to use san-router - 10 common examples

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 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 = '';
                that.data.set('content', '');
                if (query.type === 'docs') {
                    import(
                        /* webpackChunkName: "docs" */
                        `@docs/${query.id}.md?exportType=html`
                    ).then(({default: html}) => {
                        that.data.set('content', html);
                    }).catch(e => {
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-store / example / todos / src / main.js View on Github external
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-store / src / main.js View on Github external
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-esnext / src / main.js View on Github external
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 ecomfe / san-realworld-app / src / article / components / meta.js View on Github external
toggleFollow() {
        if (!this.data.get('isAuthenticated')) {
            router.locator.redirect('/login');
            return;
        }

        let author = this.data.get('article.author');
        this.actions[author.following ? 'unfollow' : 'follow'](author.username)
            .then(data => {
                this.actions.setAuthor(data.profile);
                console.log(data.profile)
            });
    },
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,
});

san-router

Router for San

MIT
Latest version published 1 year ago

Package Health Score

52 / 100
Full package analysis

Similar packages