This.$store, the this here is pointing incorrectly.

const doLogin = function (username, password, v, callback) {
};
doLogin(localStorage.username, localStorage.password, this, function (res, msg) {
        if (res) {
          this.$store.commit({
            type: "login",
            username: res.name,
            token: res.token,
          });
      });

this.$store the this here points to incorrect how to bind the outer this to the callback function

May.28,2021

use the arrow function

const doLogin = function (username, password, v, callback) {
};
doLogin(localStorage.username, localStorage.password, this, (res, msg) => {
        if (res) {
          this.$store.commit({
            type: 'login',
            username: res.name,
            token: res.token,
          });
        }
});
Menu