不使用vuejs中的路由器导航到新页面

时间:2018-04-11 05:43:52

标签: api vue.js axios vue-router

//我想在注册表格中单击提交按钮时转到另一个页面,然后在注册表单中将数据发送到我的api,以便点击提交按钮将数据移动到api。但是当我点击提交按钮时,它会将数据保存在api中,但它不会移动到我想要的pGage

a)这是我的注册HTML代码

<div class="signupbutton">
    <button type = "button" class="button-style" @click="signupMethod">Sign Up</button>
       </div>

b)这是我的signup.js代码

signupMethod() {
      const signupObj = {
        username: this.enter_details.username,
        email: this.enter_details.email,
        contactNumber: this.enter_details.contactNumber,
        firstName: this.enter_details.firstName,
        lastName:this.enter_details.lastName,
        dob: this.enter_details.dob,
        password: this.enter_details.password,
        countryCode: this.active_language
      }
        this.$store.dispatch('signupUser' , signupObj).then(()=>{
        this.app.$router.push('/mistrecord')
      })
    },

c)这是我店里的action.js

import vue from 'vue';
import vuex from 'vuex';
import axios from 'axios'
import {User} from "../../../service/onBoarding";
import {LocalData} from "../../../service/localData";
// import router from "../../../router";

vue.use(vuex);

export default{

  signupUser ({commit}, signUpObj) {

    axios.post('https://dev-api.mysc.io/int/api/v1/user/signup', signUpObj)
      .then((response) => {
        console.log(response);
        commit('setAuthToken',response.data.result.authToken);
        // this.app.$router.push('/mistrecord')
      })
      .catch((error) => {
        console.log(error);
      })

  },

成功填写注册页面后,我无法导航到mistrecord页面。请帮帮我这个

0 个答案:

没有答案