1、首先看下目录结构,不知道怎么创建项目的话,可以看 Vue3.0+typescript项目创建
2、创建一个Login.vue文件,代码:
<template>
<div>
<span>{
{username}}</span>
</div>
</template>
<script lang="ts">
import {Component, Vue} from "vue-property-decorator";
import {State, Getter, Action, Mutation, namespace} from "vuex-class";
const someModule = namespace("loginVUEX");
@Component({
name: "Login"
})
export default class Login extends Vue {
@someModule.State(state => state.username) username: any;
@someModule.Action("saveUserNameFN") saveUserNameFN: any;
@someModule.Getter('g