codecamp

router.go

router.go(path)

导航到一个新的路由

参数

  • path: String | Object

    path 可以是一个字符串,或是包含跳转信息的对象。

    当是字符串时,该路径必须为一个普通路径(也就是说没有动态片段或者全匹配片段)。路径若不是以 / 开头的绝对路径,会以相对于当前路径的方式进行解析。

    当是对象时,可以是如下的格式:

    { path: '...' }

    或是:

    {
    name: '...',
    // params 和 query 可选
    params: { ... },
    query: { ... }
    }

    关于包含 name 的路径对象,参见具名路径.

    • 当用 path 格式跳转到一个相对路径时,可以用 append: true 选项来确保该相对路径始终被添加到当前路径之后。比如:

    • /a 跳转到 b 时,若没有 append: true,则会跳转到 b;
    • /a 跳转到 b 时,若有 append: true,则会跳转到 /a/b

    • 两种格式都接受 replace: true 选项,使得该跳转不产生一个新的历史记录。
router.on
router.replace
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }