zoukankan      html  css  js  c++  java
  • vue-router-4-编程式导航

    想要导航到不同的 URL,用 router.push 方法,会向 history 栈添加一个新的记录

    <router-link> 《==》router.push

    // 字符串
    router.push('home')
    
    // 命名的路由
    router.push({ name: 'user', params: { userId: 123 }})
    
    // 对象
    router.push({ path: 'home' })
    
    // 带查询参数,变成 /register?plan=private
    router.push({ path: 'register', query: { plan: 'private' }})
    //如果提供了 path,params 会被忽略,需完整设置路径:
    const userId = 123;
    router.push({ name: 'user', params: { userId }}) // -> /user/123
    router.push({ path: `/user/${userId}` }) // -> /user/123
    //在 router.push 或 router.replace 中提供 onComplete 和 onAbort 回调作为第二个和第三个参数
    
    router.push(location, onComplete?, onAbort?)//导航成功完成或中止时
    router.replace(location, onComplete?, onAbort?)
    
    //replace它不会向 history 添加新记录
    <router-link :to="..." replace>==》
    router.replace(...)
    router.go(n)
    // 在浏览器记录中前进一步,等同于 history.forward()
    router.go(1)
    
    // 后退一步记录,等同于 history.back()
    router.go(-1)
    
    // 前进 3 步记录
    router.go(3)
    
    // 如果 history 记录不够用,那就默默地失败呗
    router.go(-100)
    router.go(100)
  • 相关阅读:
    MathType中怎么设置字体默认颜色
    MathType二次偏导怎么表示
    简单几步让你的公式逼格爆表!
    登陆
    输入框
    表单
    窗体
    hello world
    net 代码生成
    Sql_server四种执行ExecuteReader、ExecuteNonQuery、ExecuteScalar、DataSet.docx
  • 原文地址:https://www.cnblogs.com/avidya/p/7644609.html
Copyright © 2011-2022 走看看