wangguoyu 5 bulan lalu
induk
melakukan
60c0da78e4
4 mengubah file dengan 40 tambahan dan 23 penghapusan
  1. 12 7
      common/prototype.js
  2. 13 10
      components/custom-tabbar/custom-tabbar.vue
  3. 3 1
      main.js
  4. 12 5
      pages/my/index.vue

+ 12 - 7
common/prototype.js

@@ -2,10 +2,15 @@
  * @全局挂载
  * @API 全局事件
  */
-// import Aliplayer from 'aliplayer';
-	 
-// const installAliplayer = function(Vue) {
-// 	  Vue.prototype.$aliplayer = Aliplayer;
-// };
-	 
-// export default installAliplayer;
+import { reactive } from 'vue';
+
+export let state = reactive({
+  nianji: '',
+  xueqi: '',
+  zhangId: '',
+});
+
+// 你可以在这里定义修改全局状态的函数(可选)
+export function setGlobalVariable(newValue) {
+
+}

+ 13 - 10
components/custom-tabbar/custom-tabbar.vue

@@ -28,17 +28,20 @@ export default {
 	      if (queryString) {
 	        path += `?${queryString}`;
 	      }
+		  uni.navigateTo({
+		    url: path
+		  });
 	      // 使用 uni.switchTab 进行跳转(适用于 tabBar 页面)
-	      if (this.isTabBarPage(path)) {
-	        uni.switchTab({
-	          url: path
-	        });
-	      } else {
-	        // 使用 uni.navigateTo 进行跳转(适用于非 tabBar 页面)
-	        uni.navigateTo({
-	          url: path
-	        });
-	      }
+	      // if (this.isTabBarPage(path)) {
+	      //   uni.switchTab({
+	      //     url: path
+	      //   });
+	      // } else {
+	      //   // 使用 uni.navigateTo 进行跳转(适用于非 tabBar 页面)
+	      //   uni.navigateTo({
+	      //     url: path
+	      //   });
+	      // }
 	    },
 	    isTabBarPage(path) {
 	      // 根据你的 tabBar 页面路径进行判断

+ 3 - 1
main.js

@@ -4,10 +4,12 @@ import App from './App.vue'
 //import './permission' // permission
 import { createPinia } from 'pinia'
 import uviewPlus from 'uview-plus'
-import './common/prototype.js'//全局挂载
+import {state,setGlobalVariable} from './common/prototype.js'//全局挂载
 const pinia = createPinia()
 // 创建Vue应用实例
 const app = createApp(App)
+app.config.globalProperties.$state = state;
+app.config.globalProperties.$setGlobalVariable = setGlobalVariable;
 //app.use(plugins)
 app.use(createPinia())
 app.use(uviewPlus)

+ 12 - 5
pages/my/index.vue

@@ -1,6 +1,7 @@
 <template>
 	<view class="lli-develop-expect-page">
-			<button class="lli-btn" @click="quit">退出登录</button>
+			<button class="lli-btn" @click="quit">退出登录</button>
+					<CustomTabBar></CustomTabBar>
 	</view>
 </template>
 
@@ -8,8 +9,11 @@
 	import {
 		logout
 	} from '@/api/login.js'
-	
-	
+	import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
+	import { getCurrentInstance } from 'vue';
+	import {
+		onLoad,
+	} from '@dcloudio/uni-app';
 	const quitClick = ()=>{
 		uni.showModal({
 		        title: '提示',
@@ -32,8 +36,11 @@
 				url: '/pages/login/index'
 			});
 		
-		 }
-		 
+		 }
+		 onLoad((options) => {
+			const instance = getCurrentInstance();
+		 	console.log(instance.appContext.config.globalProperties)
+		 })
 	// import { ref, onMounted } from 'vue';
 	//
 	// const listData = ref([]);