Browse Source

修改首页下拉刷新

zs 1 năm trước cách đây
mục cha
commit
885d7a166e

+ 2 - 1
pages.json

@@ -12,7 +12,8 @@
 		{
 			"path": "pages/home/index",
 			"style": {
-				"navigationBarTitleText": "首页"
+				"navigationBarTitleText": "首页",
+				"enablePullDownRefresh": true
 			}
 		}
 	],

+ 5 - 1
pages/home/index.vue

@@ -13,7 +13,7 @@
 		ref
 	} from 'vue';
 	//该依赖已内置不需要单独安装
-	import { onLoad, onShow } from "@dcloudio/uni-app";
+	import { onPullDownRefresh, onShow } from "@dcloudio/uni-app";
 	// 请求接口
 	const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
 	// openid
@@ -25,6 +25,10 @@
 	onShow(() => {
 		uni.hideHomeButton();
 	})
+	// 下拉刷新
+	onPullDownRefresh(() => {
+		uni.stopPullDownRefresh()
+	})
 	// 用户信息
 	const initUser = async () => {
 		const res = await $api(`/system/matchUser/find`, 'GET', {

+ 2 - 0
unpackage/dist/dev/mp-weixin/common/vendor.js

@@ -6563,11 +6563,13 @@ const createHook = (lifecycle) => (hook, target = getCurrentInstance()) => {
   !isInSSRComponentSetup && injectHook(lifecycle, hook, target);
 };
 const onShow = /* @__PURE__ */ createHook(ON_SHOW);
+const onPullDownRefresh = /* @__PURE__ */ createHook(ON_PULL_DOWN_REFRESH);
 exports._export_sfc = _export_sfc;
 exports.computed = computed;
 exports.createSSRApp = createSSRApp;
 exports.defineComponent = defineComponent;
 exports.getCurrentInstance = getCurrentInstance;
 exports.index = index;
+exports.onPullDownRefresh = onPullDownRefresh;
 exports.onShow = onShow;
 exports.ref = ref;

+ 3 - 0
unpackage/dist/dev/mp-weixin/pages/home/index.js

@@ -12,6 +12,9 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
     common_vendor.onShow(() => {
       common_vendor.index.hideHomeButton();
     });
+    common_vendor.onPullDownRefresh(() => {
+      common_vendor.index.stopPullDownRefresh();
+    });
     const initUser = async () => {
       const res = await $api(`/system/matchUser/find`, "GET", {
         openid: openid.value

+ 1 - 0
unpackage/dist/dev/mp-weixin/pages/home/index.json

@@ -1,4 +1,5 @@
 {
   "navigationBarTitleText": "首页",
+  "enablePullDownRefresh": true,
   "usingComponents": {}
 }