unibest/src/App.vue

34 lines
956 B
Vue
Raw Normal View History

2023-12-21 15:50:52 +08:00
<script setup lang="ts">
2024-01-22 11:01:41 +08:00
import { onLaunch, onShow, onHide, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
2023-12-21 16:47:54 +08:00
2023-12-21 15:50:52 +08:00
onLaunch(() => {
2023-12-21 15:52:49 +08:00
console.log('App Launch')
})
2023-12-21 15:50:52 +08:00
onShow(() => {
2023-12-21 15:52:49 +08:00
console.log('App Show')
})
2023-12-21 15:50:52 +08:00
onHide(() => {
2023-12-21 15:52:49 +08:00
console.log('App Hide')
2024-01-22 11:01:41 +08:00
})
// App.vue里面设置的微信分享对全部页面生效TODO: 如何拿到每个页面的标题和url呢
/** 激活“分享给好友” */
onShareAppMessage((options: Page.ShareAppMessageOption): Page.CustomShareContent => {
console.log('options:', options)
return {
title: '自定义分享标题',
path: '/pages/index/index?id=xxx',
imageUrl:
'https://cip-shopping-page-0eysug01066a9e-1302818703.tcloudbaseapp.com/pretty-girl.png',
}
})
/** 激活“分享到朋友圈”, 注意:需要先激活“分享给好友” */
onShareTimeline((): Page.ShareTimelineContent => {
return {
title: '自定义分享标题',
query: 'a=1&b=2',
}
2023-12-21 15:52:49 +08:00
})
2023-12-21 15:50:52 +08:00
</script>