Advertisement

cart 实战 voom

阅读量:

store模块创建与实现

1、于 store 目录下创建 modules/carts.js 文件,并编写 store 的基本结构格式

复制代码
    const state = () => ({
      count: 10, // 定义 count 属性,默认值为 10
    });
    
    const getters = {};
    
    const actions = {};
    
    const mutations = {};
    
    export default {
      namespaced: true,
      state,
      getters,
      actions,
      mutations,
    };
    
    

2、在任意一个部件中

复制代码
    <h3>{{ count }}</h3>
    
    import { mapState } from "vuex";
    
    computed: {

全部评论 (0)

还没有任何评论哟~