使用:Reaction、WordPress REST API、Axios
我从一个定制的POST类型中提取结果,当我获得文本框字段"acf.ther"的结果时,每当用户输入回车时,它都会放入<br />
标记、</p> <p>
标记或不放任何标记,从而导致连续的段落不带格式.如果它放置标签,那么结果会显示站点上的标签,而不是实际使用标签(见img).screenshot of results
export const SingleRecent = () => {
const { singleSlug } = useParams();
const [single,setSingle] = useState([]);
useEffect(() => {
axios.get(recent + singleSlug)
.then(response => {
setSingle(response.data);
})
.catch((error) => {
console.log(error);
})
}, [singleSlug]);
return (
<><div className="pagebg singlePageBg">
<main>
<div className="container notHomeContainer singleContainer">
<div className="gallery notHomeGallery singleGallery">
{single.map(single_recent => <SingleRecentItems key={single_recent.id} single_recent={single_recent} />)}
</div>
</div>
</main>
</div></>
);
}
class SingleRecentItems extends Component {
render() {
let { acf } = this.props.single_recent;
return (
<>
<h1>{acf.title}</h1>
<h4>{acf.style}</h4>
<div className="photos">
<span className="recentPhoto">
<img
src={acf.photo}
alt={acf.title}
/>
</span>
</div>
<div className="otherInfo">
{acf.other}
</div>
<div className="location">
Photo Taken in: {acf.location_other}<br />
{acf.location_city}<br />
{acf.location_state}<br />
{acf.location_country}
</div>
<div className="keywords">
{acf.subject}
</div>
</>
)
}
}
我希望获得{acf.other}
的结果,并将标记转换为功能标记,以便它将以用户希望的方式(或多或少)格式化结果.我可以以某种方式将{acf.other}
赋给一个变量,解析和连接,然后返回结果吗?有没有更好的办法?