On the problem of this.$store.commit () in vuex

1. I don"t understand many places when I use vuex, for the first time. The account number and password entered are correct. The landing page uses this.$store.commit ("token", res.data.data) to report an error

.

clipboard.png

main.js

import Vuex from "vuex"
Vue.use(Vuex)

login page

    <div class="login_form">
      <el-form :label-position="labelPosition" label-width="80px" :model="form">
        <el-form-item>
          <i class="account_icon"></i>
          <el-input v-model="form.userName" placeholder=""></el-input>
        </el-form-item>
        <el-form-item prop="password">
          <i class="password_icon"></i>
          <el-input type="password" v-model="form.password" auto-complete="off" placeholder=""></el-input>
        </el-form-item>
        <div class="checkbox">
          <input type="checkbox">
          <span class="login_password"></span>
        </div>
        <div>
          <button @click="onSubmit" :plain="true"></button>
        </div>
        <div class="login_embellish">
          <i class="embellish_one"></i>
        </div>
      </el-form>
      <i class="modifier_left"></i>
      <i class="modifier_right"></i>
    </div>

js

export default {
  data() {
    return {
      labelPosition: "right",
      form: {
        userName: "",
        password: ""
      }
    }
  },
  methods: {
    onSubmit() {
      let paramsData = {
        username: this.form.userName,
        password: this.form.password
      };
      this.$ajax.post(this.$api.Login, paramsData).then(res => {
        if (res.status == 200) {
          console.log("res", res);
          this.$store.commit("token", res.data.data)
          if(res.data.status == 401) {
            this.$message.error(res.data.message);
          }
        }
      })
      .catch(err => {
        console.log(err);
      })
    }
  }
}
Mar.10,2021

see if you forgot to inject state into the instance
vuex document

  

this.$store is undefined , of course it is wrong

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e2fa94-4406c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e2fa94-4406c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?