hookehuyr

测试模拟onshow事件

...@@ -68,6 +68,7 @@ const config = { ...@@ -68,6 +68,7 @@ const config = {
68 "@/composables": path.resolve(__dirname, "../src/composables"), 68 "@/composables": path.resolve(__dirname, "../src/composables"),
69 "@/api": path.resolve(__dirname, "../src/api"), 69 "@/api": path.resolve(__dirname, "../src/api"),
70 "@/stores": path.resolve(__dirname, "../src/stores"), 70 "@/stores": path.resolve(__dirname, "../src/stores"),
71 + "@/hooks": path.resolve(__dirname, "../src/hooks"),
71 }, 72 },
72 sourceRoot: 'src', 73 sourceRoot: 'src',
73 outputRoot: 'dist', 74 outputRoot: 'dist',
......
1 +/*
2 + * @Date: 2022-11-02 13:27:01
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2022-11-02 13:32:23
5 + * @FilePath: /swx/src/hooks/life.js
6 + * @Description: 封装小程序页面生命周期
7 + */
8 +import { getCurrentInstance } from '@tarojs/taro'
9 +import { onMounted } from 'vue'
10 +
11 +const Current = getCurrentInstance()
12 +
13 +export function useDidShow(callback) {
14 + onMounted(callback); Current?.page?.onShow && (Current.page.onShow = callback)
15 +}
16 +export function usePullDownRefresh(callback) {
17 + Current?.page?.onPullDownRefresh && (Current.page.onPullDownRefresh = callback)
18 +}
1 <!-- 1 <!--
2 * @Date: 2022-09-19 14:11:06 2 * @Date: 2022-09-19 14:11:06
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-11-01 09:28:54 4 + * @LastEditTime: 2022-11-02 13:43:51
5 * @FilePath: /swx/src/pages/index/index.vue 5 * @FilePath: /swx/src/pages/index/index.vue
6 * @Description: 首页 6 * @Description: 首页
7 --> 7 -->
...@@ -37,6 +37,12 @@ import { ref } from 'vue'; ...@@ -37,6 +37,12 @@ import { ref } from 'vue';
37 import activityCard from '@/components/activity-card.vue' 37 import activityCard from '@/components/activity-card.vue'
38 import navbar from '@/components/navbar.vue' 38 import navbar from '@/components/navbar.vue'
39 import Toast from '@/components/vant-weapp/toast/toast'; 39 import Toast from '@/components/vant-weapp/toast/toast';
40 +// import { useDidShow } from '@/hooks/life'
41 +import { useDidShow } from '@tarojs/taro'
42 +// TAG: 模拟onShow事件
43 +useDidShow(() => {
44 + console.warn('onShow')
45 +})
40 46
41 const goTo = (id) => { 47 const goTo = (id) => {
42 Taro.navigateTo({ 48 Taro.navigateTo({
......