Merge pull request '加入pinia并测试以便加入购物车功能的实现' (#35) from Brunch_DBK into main

pull/39/head
pikvyz67s 2 months ago
commit 33d0cdd2a9

File diff suppressed because it is too large Load Diff

@ -52,6 +52,7 @@
"@dcloudio/uni-mp-weixin": "3.0.0-4070520250711001",
"@dcloudio/uni-mp-xhs": "3.0.0-4070520250711001",
"@dcloudio/uni-quickapp-webview": "3.0.0-4070520250711001",
"pinia": "^3.0.3",
"vue": "^3.4.21",
"vue-i18n": "^9.1.9"
},

@ -1,14 +1,17 @@
import {
createSSRApp
} from "vue";
import * as Pinia from 'pinia';
// 引入 uView UI
import uView from './uni_modules/vk-uview-ui';
import App from "./App.vue";
export function createApp() {
const app = createSSRApp(App);
app.use(Pinia.createPinia());
// 使用 uView UI
app.use(uView);
return {
app,
Pinia,
};
}

@ -39,6 +39,14 @@
结算({{totalNum}})
</view>
</view>
<view class="">
<view class="">
{{store.count}}
</view>
<view class="" @click="store.increment">
新增
</view>
</view>
</template>
<script setup>
@ -47,6 +55,11 @@
reactive,
computed
} from 'vue'
import {
carStore
} from '../../store/car.js'
//store
const store = carStore();
const show = ref(true);
const allchecked = ref(true);
const checked = ref(true);

@ -0,0 +1,15 @@
// 引入
import { defineStore } from 'pinia';
//定义store
export const carStore = defineStore('carStore', {
state: () => {
return { count: 0 };
},
// 也可以这样定义
// state: () => ({ count: 0 })
actions: {
increment() {
this.count++;
},
},
});
Loading…
Cancel
Save