Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
swx_weapp
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2022-11-02 13:48:40 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a4ac3cc9726daadb92a1662fb6d59dfdd3b12756
a4ac3cc9
1 parent
33dfb182
测试模拟onshow事件
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
1 deletions
config/index.js
src/hooks/life.js
src/pages/index/index.vue
config/index.js
View file @
a4ac3cc
...
...
@@ -68,6 +68,7 @@ const config = {
"@/composables": path.resolve(__dirname, "../src/composables"),
"@/api": path.resolve(__dirname, "../src/api"),
"@/stores": path.resolve(__dirname, "../src/stores"),
"@/hooks": path.resolve(__dirname, "../src/hooks"),
},
sourceRoot: 'src',
outputRoot: 'dist',
...
...
src/hooks/life.js
0 → 100644
View file @
a4ac3cc
/*
* @Date: 2022-11-02 13:27:01
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-11-02 13:32:23
* @FilePath: /swx/src/hooks/life.js
* @Description: 封装小程序页面生命周期
*/
import
{
getCurrentInstance
}
from
'@tarojs/taro'
import
{
onMounted
}
from
'vue'
const
Current
=
getCurrentInstance
()
export
function
useDidShow
(
callback
)
{
onMounted
(
callback
);
Current
?.
page
?.
onShow
&&
(
Current
.
page
.
onShow
=
callback
)
}
export
function
usePullDownRefresh
(
callback
)
{
Current
?.
page
?.
onPullDownRefresh
&&
(
Current
.
page
.
onPullDownRefresh
=
callback
)
}
src/pages/index/index.vue
View file @
a4ac3cc
<!--
* @Date: 2022-09-19 14:11:06
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-11-0
1 09:28:54
* @LastEditTime: 2022-11-0
2 13:43:51
* @FilePath: /swx/src/pages/index/index.vue
* @Description: 首页
-->
...
...
@@ -37,6 +37,12 @@ import { ref } from 'vue';
import activityCard from '@/components/activity-card.vue'
import navbar from '@/components/navbar.vue'
import Toast from '@/components/vant-weapp/toast/toast';
// import { useDidShow } from '@/hooks/life'
import { useDidShow } from '@tarojs/taro'
// TAG: 模拟onShow事件
useDidShow(() => {
console.warn('onShow')
})
const goTo = (id) => {
Taro.navigateTo({
...
...
Please
register
or
login
to post a comment