2017-06-14 7 views
0

私はアプリケーションを作成していますが、Signupをクリックするとregister()が実行され、約束を返してログインにルーティングしますルート。代わりに、同じサインアップページに滞在のVue.jsを使用してボタンをクリックした後に別のコンポーネントを読み込む方法

は、私は、ログインページ

register(){ 

    axios.post('url', { 

    username: this.username, 
    password:this.password 
    }) 
    .then(function (response) { 
    console.log(response); 

    }) 
    .catch(function (error) { 
    console.log(error); 
    }); 
+0

あなたは 'vue-router'を使っていますか? – Bert

+0

@ BertEvans..Yes私はvue-routerを使用しています – Artwell

答えて

2

ルータの使用push()にルーティングするようにしたいです。

.then(function (response) { 
    console.log(response); 
    this.$router.push('login'); 
}) 

Vue-routerはprogrammatic navigationです。

+0

私は別のコンポーネントで使用できるようにルータをエクスポートできますか? – Artwell

+0

@Artwell $ routerは* all *コンポーネントで使用できます。 – Bert

+0

@BertEvansが正しいです。あなたの質問に答えるために、はい、それをエクスポートして別のコンポーネントで使用することもできます。ここに例があります... https://github.com/theosherman/insulin-calculator/blob/master/src/router/index.js – Theo

関連する問題