Code Monkey home page Code Monkey logo

vuex-vue-router--login's Issues

跳转问题

我改了下你的代码,前端get username和password到后端,后端判断后为真就返回1给前端。
前端在判断跳转到想要的路径。
但是现在前后端都可以交互,就是无法跳转。下面上代码

    methods: {
        resetForm:function(){
            this.formName.user = '';
            this.formName.userError = '';
            this.formName.password = '';
            this.formName.passwordError = '';
        },
        isLogin:function(){
            //与父组件通信传值
            //this.$emit('showState', [this.beShow,this.formName.user])
            //提交username password
            var user = this.formName.user,
                password = this.formName.password;
                console.log(user,password)
            axios.get('/login',{
                params: {
                    user: user,
                    password: password
                }
              })
              .then((res) => {
                  console.log(res.data.result);
                  if (res.data.result == 1) {
                      this.formName.user = '';
                      this.formName.password = '';
                      this.$router.push({path:'top'});
                  } else {
                     this.$notify.error({title:'Login Error',
                                         message:'用户名或密码错误!!!',
                                         offset:100
                     });
                     this.formName.user = '';
                     this.formName.password = '';
                  }
              })
              .catch(function(err){
                  console.log(err);
              });
        },

我加上 this.$store.commit('isLogin'); 后提示 commit of undefined

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.