HTML5   发布时间:2022-04-25  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了html5 – 混合JSON-LD和Microdata Schema.org大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
如果我有以下标记

<body itemscope="" itemtype="http://scheR_297_11845@a.org/WebPage">
  <h1 itemprop="name">Lecture 12: Graphs,networks,incidence matrices</h1>
  <p itemprop="description">these video lectures of Professor Gilbert
    Strang teaching 18.06 were  recorded in fall 1999 and do not
    correspond precisely to the current  edition of the textbook.</p>
  <div itemprop="publisher" itemscope="" itemtype="http://scheR_297_11845@a.org/CollegeOrUniversity">
    <h4 class="footer">About <span itemprop="name">MIT OpenCourseWare</span></h4>
  </div>
  <a itemprop="license"
    rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/deed.en_US"><img
    src="/images/cc_by-nc-sa.png" alt="Creative Commons logo with terms BY-NC-SA." /></a>
</body>

我想重构发布者属性,因为它很复杂,我不想显示并执行此操作:

<body itemscope="" itemtype="http://scheR_297_11845@a.org/WebPage">
  <h1 itemprop="name">Lecture 12: Graphs,incidence matrices</h1>
  <p itemprop="description">these video lectures of Professor Gilbert
    Strang teaching 18.06 were  recorded in fall 1999 and do not
    correspond precisely to the current  edition of the textbook.</p>
  <script type="application/ld+json">
    {
        "@context": "http://scheR_297_11845@a.org","@type": "CollegeOrUniversity","name": "MIT OpenCourseWare"
    }
</script>
  <a itemprop="license"
    rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/deed.en_US"><img
    src="/images/cc_by-nc-sa.png" alt="Creative Commons logo with terms BY-NC-SA." /></a>
</body>

怎么说< script>块与itemprop =“publisher”属性有关?

我想这两个选项是i).将itemprop属性添加到脚本标记或ii).将@attribute添加到代替itemprop到JSON-LD块.

我也找不到任何文档.有人知道答案吗?

解决方法

是不可能的.如果在脚本元素上使用itemprop属性,则为脚本的 property value will be the textContent.这基本上类似于itemprop =“{”@ context“:”http://scheR_297_11845@a.org“,”@ type“:”CollegeOrUniversity“,”name“:”MIT OpenCourseWare“}”,所以价值是纯文本,而不是JSON-LD(并不解释为JSON-LD).

如果您不希望在页面显示发布者名称,则可以使用元元素:

<div itemprop="publisher" itemscope itemtype="http://scheR_297_11845@a.org/CollegeOrUniversity">
  <Meta itemprop="name" content="MIT OpenCourseWare" />
</div>

也可以将node identifier (@id)用于JSON-LD节点并在Microdata中引用此URI,但有些消费者可能不支持它(有些可能根本不遵循引用,有些可能只能识别scheR_297_11845@a.org对publisher的期望property:Organization / Person,但不是URL):

<script type="application/ld+json">
{
    "@context": "http://scheR_297_11845@a.org","@id": "http://example.com/mit-opencourseware#thing","name": "MIT OpenCourseWare"
}
</script>
<link itemprop="publisher" href="http://example.com/mit-opencourseware#thing" />

大佬总结

以上是大佬教程为你收集整理的html5 – 混合JSON-LD和Microdata Schema.org全部内容,希望文章能够帮你解决html5 – 混合JSON-LD和Microdata Schema.org所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。