import { useState } from 'react' import { View, Text } from '@tarojs/components' import { useLoad } from '@tarojs/taro' import { fetchDestination, type Destination } from '../../services/api' import './index.scss' export default function DestinationPage() { const [d, setD] = useState(null) const [err, setErr] = useState('') useLoad((q) => { const slug = String(q.slug || '') if (!slug) { setErr('缺少城市'); return } fetchDestination(slug).then(setD).catch((e) => setErr(e.message || '加载失败')) }) if (err) return {err} if (!d) return 加载中… return ( {d.name} {d.country} {d.tagline} 月生活费¥{d.cost ?? '—'} 网速{d.speed ?? '—'} Mbps 评分{d.rating ?? '—'} 气候{d.climate || '—'} ) }