"use client"; import React, { useEffect, useState } from "react"; import Image from "next/image"; import axios from "axios"; export default function Faqs() { const [data, setData] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { async function fetchData() { try { setLoading(true); const res = await axios.get("/api/get-component-data", { params: { component_name: "Faqs" }, }); setData(res.data.data); } catch (err) { setError("获取Faqs数据失败"); } finally { setLoading(false); } } fetchData(); }, []); if (loading) return
Loading...
; if (error || !data) return null; // 主表字段 const title = data.title || "Our Products"; const subtitle = data.subtitle || ""; const buttonText = data.button_text || "MORE"; const buttonLink = data.button_link || "#"; // 子表items const items = Array.isArray(data.items) ? data.items.slice(0, 6) : []; return (
image

{data.p1}

{/* 描述 */}

{data.description}

{/* 按钮 */} {buttonText}
{/*/column */}

{title}

{subtitle}

{items.map((item, idx) => { const headingId = `heading-${idx}`; const collapseId = `collapse-${idx}`; return (

{item.item_description}

); })}
{/*/column */}
{/*/.row */}
{/* /.container */} {/* /.container */}
); }