This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
// 导出一个默认的模块对象
export default {
// 启用命名空间,使得该模块的状态和getters、actions、mutations是注册在全局命名空间下的子模块
namespaced: true,
// 定义模块的初始状态
state: {
id: 0, // 初始化 id 为 0
name: '' // 初始化 name 为空字符串
},
// 定义用于修改状态的 mutations
mutations: {
// 更新 id 的 mutation
updateId(state, id) {
state.id = id; // 将传入的 id 赋值给 state 中的 id
// 更新 name 的 mutation
updateName(state, name) {
state.name = name; // 将传入的 name 赋值给 state 中的 name
}