创建一个用于写数据管理的store.js
import { createStore } from "vuex";
interface State {
userName: string;
}
export default createStore({
state: {
userName: "小米",
},
});
在main.js中引入
import { createApp } from "vue";
import App from "./App.vue";
import "./index.css";
import router from "../router/index";
import vuex from "../store/index";
// createApp(App).mount("#app");
const app = createApp(App);
app.use(router);
app.use(vuex);
app.mount("#app");