PanJiaChen / vue-element-admin

:tada: A magical vue admin https://panjiachen.github.io/vue-element-admin
MIT License
87.61k stars 30.43k forks source link

Change tab url with router #1739

Open elsiosanchez opened 5 years ago

elsiosanchez commented 5 years ago

Hi, I have a question about when I have a tab window when I change the tab, I do not change the url Screenshot_20190319_114941 Screenshot_20190319_114915

PanJiaChen commented 5 years ago

Sorry, I didn't understand what you want to ask.

elsiosanchez commented 5 years ago

my question is that in the tab component when I change the tab from CHINA to USA it does not show me in the url in which tab number I'm stopped if it's in 1, 2, 3 or 4 Screenshot_20190322_082223

How would I know in which position of tab tab component I am selecting and to show it in the url

elsiosanchez commented 5 years ago

I tried to do it with the router-link but when I change tab tab component duplicates the example window (if I try to change from the USA tab that is in position 2 to EUROZONE that is in position 4 another window opens and happens every time you change the tab) as seen in the image Screenshot_20190322_091540

Screenshot_20190322_092859

PanJiaChen commented 5 years ago

In @/views/tab/index.vue add

watch: {
    activeName(val) {
      this.$router.push(`${this.$route.path}?tab=${val}`)
    }
  },

In @/view/layout/components/AppMain.vue remove

- <router-view :key="key" />
+ <router-view  />
elsiosanchez commented 5 years ago

Good morning if it works, but only when the component has 2 or 3 tab, I have a doubt there is no way to solve them by parametos

leonel1524 commented 5 years ago

Hi @PanJiaChen, I have the same problem, I need to click on a tab, the URL change the value of a parameter and do not reload the page and also open the component again.