如何在网页中调用并显示 JSON-LD 数据:抖音面包屑导航示例
<html>
<head>
<title>示例</title>
<script data-react-helmet='true' type='application/ld+json'>
{
'@context': 'https://schema.org',
'@type': 'BreadcrumbList',
'itemListElement': [{
'@type': 'ListItem',
'position': 1,
'name': '抖音',
'item': 'https://www.douyin.com'
},{
'@type': 'ListItem',
'position': 2,
'name': 'PPT之神',
'item': 'https://www.douyin.com/user/MS4wLjABAAAA0C2JbrxnSTOwABi8POWTMj6xdD0ONNpV_0S3NiM0RsXzdxxiO87MHlfa7WfURQ1q'
}]
}
</script>
</head>
<body>
<script type='text/javascript'>
var script = document.querySelector('script[data-react-helmet="true"]');
console.log(JSON.parse(script.textContent));
</script>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/l4fx 著作权归作者所有。请勿转载和采集!