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