From a1c9ab0037bcfb14b23e7a19fcd7b8c4cd7a73fe Mon Sep 17 00:00:00 2001 From: chenhaizhao <2291973799@qq.com> Date: Mon, 22 Dec 2025 17:24:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 25 +++++++++++++------------ pages/index/index.vue | 2 +- store/index.js | 10 ++++++++++ 3 files changed, 24 insertions(+), 13 deletions(-) create mode 100644 store/index.js diff --git a/main.js b/main.js index c1caf36..9d0e354 100644 --- a/main.js +++ b/main.js @@ -1,20 +1,21 @@ import App from './App' +// // #ifndef VUE3 +// import Vue from 'vue' +// import './uni.promisify.adaptor' +// Vue.config.productionTip = false +// App.mpType = 'app' +// const app = new Vue({ +// ...App +// }) +// app.$mount() +// // #endif -// #ifndef VUE3 -import Vue from 'vue' -import './uni.promisify.adaptor' -Vue.config.productionTip = false -App.mpType = 'app' -const app = new Vue({ - ...App -}) -app.$mount() -// #endif - -// #ifdef VUE3 +// // #ifdef VUE3 import { createSSRApp } from 'vue' +import pinia from './store' export function createApp() { const app = createSSRApp(App) + app.use(pinia) return { app } diff --git a/pages/index/index.vue b/pages/index/index.vue index 19df931..fb6e625 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -30,7 +30,7 @@ function change(){ - + {{ list[item - 1]?.title }} diff --git a/store/index.js b/store/index.js new file mode 100644 index 0000000..537d55d --- /dev/null +++ b/store/index.js @@ -0,0 +1,10 @@ +import { createPinia } from 'pinia' +import piniaPersist from 'pinia-plugin-persistedstate' + +// 创建 pinia 实例 +const pinia = createPinia() +// 使用持久化存储插件 +pinia.use(piniaPersist) + +// 默认导出,给 main.ts 使用 +export default pinia \ No newline at end of file