wangxy 5 månader sedan
förälder
incheckning
150678c6f7
3 ändrade filer med 21 tillägg och 17 borttagningar
  1. 10 1
      components/catalogue/catalogue.vue
  2. 3 10
      components/catalogue/useCatalogue.js
  3. 8 6
      pages/study/index.vue

+ 10 - 1
components/catalogue/catalogue.vue

@@ -49,10 +49,19 @@
 	
 	const $emit = defineEmits(['change-zhang'])
 	
+	const props = defineProps({
+		nianji: {
+			type: [String,Number],
+		},
+		xueqi: {
+			type: [String,Number],
+		}
+	})
 	
 	const {
 		getCatalogue,
-	} = useCatalogue();
+	} = useCatalogue(props);
+	
 	const popupRef = ref(null); // 索引
 	const list = ref([]); // 章节
 	const activeCollapse = ref('');

+ 3 - 10
components/catalogue/useCatalogue.js

@@ -11,21 +11,14 @@ import {
 } from "@/utils/common.js"
 import * as httpCatalogue from "@/api/catalogue.js"
 
-export function useCatalogue() {
+export function useCatalogue(props) {
 	const data = reactive({
 		xueqi: null,
 		nianji: null
 	})
 
-	onLoad((options = {}) => {
-		const {
-			xueqi,
-			nianji
-		} = options;
-		data.nianji = nianji;
-		data.xueqi = xueqi;
-	})
-
+	data.nianji = props.nianji;
+	data.xueqi = props.xueqi;
 
 	async function getCatalogue() {
 		return await catchError(httpCatalogue.getCatalogue({

+ 8 - 6
pages/study/index.vue

@@ -25,9 +25,8 @@
 
 		<!-- 蛋 -->
 		<view class="ezy-popup">蛋</view>
-
-
-		<catalogue ref="catalogueRef" @change-zhang="handleChangeZhang"></catalogue>
+		
+		<catalogue ref="catalogueRef" :nianji="routeParams.nianji" :xueqi="routeParams.xueqi" @change-zhang="handleChangeZhang"></catalogue>
 	</view>
 </template>
 
@@ -39,7 +38,8 @@
 	} from "vue";
 	import {
 		onLoad,
-		onReady
+		onReady,
+		onShow,
 	} from '@dcloudio/uni-app';
 	import catalogue from "@/components/catalogue/catalogue.vue";
 	import {
@@ -54,12 +54,14 @@
 	// 来自单元测试的路由参数缓存
 	const routeParams = ref(null);
 
-	onLoad((options) => {
-		gradeTerm.value = options;
+	onShow(() => {
+		console.log('show')
 		// 获取路由参数
 		routeParams.value = getStudyStorage();
 		// 移除缓存
 		removeStudyStorage();
+		// 赋值
+		gradeTerm.value = routeParams.value;
 	})
 
 	const data = reactive({