文章详情
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { useState, useMemo, useCallback } from 'react'
|
||||
import Taro, { useRouter } from '@tarojs/taro'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { View, Text, Image, ScrollView, Input } from '@tarojs/components'
|
||||
import { Icon } from '@antmjs/vantui'
|
||||
import { getArticleDetail } from '@/mock/articleDetail'
|
||||
@@ -14,9 +14,7 @@ function getStatusBarH(): number {
|
||||
}
|
||||
|
||||
export default function ArticleDetail() {
|
||||
// useRouter 在部分 Taro 版本首次渲染 params 为空,用 getCurrentInstance 兜底
|
||||
const router = useRouter()
|
||||
const id = router.params.id || Taro.getCurrentInstance().router?.params?.id
|
||||
const id = String(Taro.getCurrentInstance().router?.params?.id || 1)
|
||||
const article = useMemo(() => (id ? getArticleDetail(id) : null), [id])
|
||||
const [commentText, setCommentText] = useState('')
|
||||
const [commentList, setCommentList] = useState<Comment[]>(comments)
|
||||
|
||||
Reference in New Issue
Block a user