0

I'm in trouble with vue-router :) I create a simple map for router :

module.exports = {
  '/': {
    component: require('./views/home')
  },
  '/auth/login': {
    component: require('./views/auth/login')
  },
  '/auth/register': {
    component: require('./views/auth/register')
  },
  '/resumes': {
    component: require('./views/resumes')
  },
  // 404 NotFound
  '*': {
    component: {
      template: "not found"
    }
  }
};

And define router to vue and it works perfectly. My home page js codes :

module.exports = {
  inherit: true,
  template: require('./template.html'),
  ready: function() {
    if(this.isLoggedIn)
    this.$route.router.go('/resumes');
  }
};

I want to load resumes page if user logged in. When I use it in any event or with v-link directive, it works normal. But if I use it on ready function, it duplicates pages. It calls home page and appends second page on it.

IMG : http://imageshack.com/a/img540/9409/3DK1ZL.jpg

Whats wrong? How can I solve it? I am dealing about 4 days with this problem. Please help me guys.

2
  • It's possible the router isn't initialized when "ready" fires. Have you tried moving that code into a this.$nextTick()? Commented Aug 24, 2015 at 12:50
  • Not only that, you can try to replate this.$route.router with this.$router and use other lifecycle triggers such as attached vuejs.org/api/#attached or router triggers such as activate or data vuejs.github.io/vue-router/en/pipeline/activate.html Commented Jan 23, 2016 at 23:53

1 Answer 1

0

this.$route.router.go('/resumes') has already been removed since Vue 2.0.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.