博客
关于我
vue中url的跳转以及参数获取
阅读量:492 次
发布时间:2019-03-07

本文共 961 字,大约阅读时间需要 3 分钟。

vue页面跳转url和参数获取

起因 :

  • 这两天因为工作需求, 需要做两个页面跳转(原本是表单的来回弹出,),本来只是一个小小的需求, 怎么想到, 我一个java的小白,
    居然在百度来回查找vue的小知识, 但是很幸运的是我找到了不少, 然后本地测了好多, 由于有一些搞不懂,
    所以就只留了两套自己可以看懂的来记录一下.
    来吧,展示 :
  • 首先, 先从一个页面的跳转记录起来,
  • 1 第一种写法:  this.$router.push({ name: 'claimApplicationdexAct', query: { accountId1: this.roleFormTemp0.accountId0 } })

这种写法其实很好理解 name : 路径的别名(也可以用path: ‘跳转的url’ 来代替) , 后半部分: query 代表一个对象(虽然params也可以代表), query和params在用法上大致相当, 只是query代表 着公开, params代表了 隐私(个人这么理解) 当你想要在url展示点东西的时候 你可以用query来携带参数 ,

例如: 在这里插入图片描述
而我还是喜欢隐藏一下 s♪(・ω・)ノ
我使用的是params
效果: 在这里插入图片描述
第二种方法:
this.$router.replace(‘要访问的url’)
// 我也没搞懂这个方法, 反正用着好使就得嘞

接收路径参数:

  • 1 this.$route.params.参数名称

    这样就拿到想要拿的那个参数的值了, 与上面两个跳转是相对应的用法

    但是一定要注意 跳转路径为 " r o u t e r " ∗ ∗ 接 收 参 数 为 ∗ ∗ " router"** 接收参数为 **" router""route"

  • 2 var test = window.location.href;

    var accountId = test.split("?accountId1=")[1];
    这个方法其实还是蛮好理解的, window.location.href 是获取 一条url ,
    然后通过对其截取的办法 去拿取参数 , 类似于java中的分割字符串, 在指定位置截取以后 拿到我们想要的参数值.

我是小宁, 一个渴望摆脱现状而又没有动力去行动的菜鸟

转载地址:http://pbjcz.baihongyu.com/

你可能感兴趣的文章
nmon_x86_64_centos7工具如何使用
查看>>
NN&DL4.1 Deep L-layer neural network简介
查看>>
NN&DL4.3 Getting your matrix dimensions right
查看>>
NN&DL4.7 Parameters vs Hyperparameters
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>
No module named 'pandads'
查看>>
No module named cv2
查看>>