使用Taro框架,分享页很简单只加了分享功能,下面是分享页代码,这是页面结构
import { View } from "@tarojs/components";
import Taro, { useRouter, useShareAppMessage, useShareTimeline } from "@tarojs/taro"
import CustomNavbar, { customHeight } from '@/components/custom-navbar'
export default () => {
useShareAppMessage((res) => {
if (res.from === 'button') {
// 来自页面内转发按钮
console.log(res.target)
}
const id = Taro.getStorageSync('id')
return {
title: 'cdca',
path: `/animal-box/pages/share/index?id=${id}`,
}
})
useShareTimeline(() => {
const id = Taro.getStorageSync('id')
return {
title: 'cdac',
query: `id=${id}`,
path: `/animal-box/pages/share/index?id=${id}`,
}
})
return (
<View style={{ marginTop: `${customHeight}px`}}>
<CustomNavbar />
Share Page
</View>
);
}
你在开发工具上,模拟分享,访问,能不能访问