Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

两个带参数路由菜单公用一个VUE页面问题 #542

Closed
ycw01 opened this issue Sep 17, 2019 · 8 comments
Closed

两个带参数路由菜单公用一个VUE页面问题 #542

ycw01 opened this issue Sep 17, 2019 · 8 comments

Comments

@ycw01
Copy link

ycw01 commented Sep 17, 2019

版本号:2.0.2
问题描述:

1、根据官方文档配置带参数路由菜单
2、配置路由菜单:/demo/demo/:code
3、配置具体菜单a:/demo/demo/:1
4、配置具体菜单b:/demo/demo/:2
5、操作步骤:
①单独 打开a菜单,可以在VUE页面获取code参数为1
②单独打开b菜单,可以在VUE页面获取code参数为2
③问题:先打开a菜单,获取VUE页面参数为1;同时打开b菜单,获取参数仍然为1,且没有进入created ()

截图&代码:

友情提示: 未按格式要求发帖,会直接删掉。

@ycw01
Copy link
Author

ycw01 commented Sep 17, 2019

经过排查后解决,但不知是否是最优方案,请大神赐教。
问题原因:路由发生变化,没有重新加载数据。
解决方案:VUE页面增加路由监听,发生变化后修改url参数,并重新加载数据。
示例代码:
watch: {
'$route' (to, from) { //监听路由是否变化
if(to.params.code!= from.params.code){
this.url.list="/demo/demo/list?code="+this.$route.params.code;
this.url.exportXlsUrl="/demo/demo/exportXls?code="+this.$route.params.code;
this.url.importExcelUrl="/demo/demo/importExcel?code="+this.$route.params.code;
this.loadData();
}
}
}

@zhangdaiscott
Copy link
Member

就应该你这么做,暂时没其他方案

@ycw01
Copy link
Author

ycw01 commented Sep 17, 2019

就应该你这么做,暂时没其他方案

还有一个问题:
在打开a或b具体路由的情况下,如果刷新浏览器,title会变成配置路由菜单的title,不是当前的具体路由的title

@archorfight
Copy link

请问一下在vue页面是怎样获取的code参数? 我在created里面和mounted里面 this.$router.param 和 query都没拿不到。

@ycw01
Copy link
Author

ycw01 commented Nov 13, 2019

请问一下在vue页面是怎样获取的code参数? 我在created里面和mounted里面 this.$router.param 和 query都没拿不到。

param少了个s

@archorfight
Copy link

我也遇到 在打开a或b具体路由的情况下,如果刷新浏览器,title会变成配置路由菜单的title,不是当前的具体路由的title 。这个问题,请问你有解决吗?

@ycw01
Copy link
Author

ycw01 commented Nov 13, 2019

我也遇到 在打开a或b具体路由的情况下,如果刷新浏览器,title会变成配置路由菜单的title,不是当前的具体路由的title 。这个问题,请问你有解决吗?

没有

@lzh1024
Copy link

lzh1024 commented Jun 22, 2021

官方文档可能写错了,我今天尝试了一下把配置菜单的“是否路由菜单“为否,具体菜单“是否路由菜单”为是就行了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants