diff --git a/src/store/product.js b/src/store/product.js new file mode 100644 index 0000000..91dea69 --- /dev/null +++ b/src/store/product.js @@ -0,0 +1,23 @@ +import {defineStore} from 'pinia' + + +export const useProductStore = defineStore('product', { + state: () => ({ + products: [], + total: 0, + }), + actions: { + productSet(data,total) { + this.products = data; + // this.products.push(...data); //追加数据 + this.total=total; //这里会更新 + }, + productTotalSet(total){ + this.total=total + } + }, + getters: { + count: (state) => state.products.length, + total: (state) => state.total, + } + }) \ No newline at end of file diff --git a/src/views/about.vue b/src/views/about.vue index 677b87d..ee12c8d 100644 --- a/src/views/about.vue +++ b/src/views/about.vue @@ -2,7 +2,7 @@

hello about

-

Count: {{ tokenStore.count }}

+

Count: {{ productStore.count }}