小编Met*_*eor的帖子

HTML5微数据 - itemref到另一个itemscope(人为组织工作)

一个组织的网站,比如"Sun Industries",想要添加一份员工名单.组织的地址和联系信息已存在于网页上,但员工列表将位于其他位置.

所以我们有

<div id="organization" itemscope itemtype="http://schema.org/Organization">
  <span itemprop="name">Sun Industries</span>,
  <span itemprop="location" itemscope itemtype="http://schema.org/Place">
    <span itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
      <span itemprop="streetAddress">Technologies Street 42</span>,
      <span itemprop="addressLocality">Venustown</span>
      <span itemprop="postalCode">98765</span>
    </span>
  </span>
</div>
Run Code Online (Sandbox Code Playgroud)

以后我们将在HTML5代码中

<div id="employee-1" itemscope itemtype="http://schema.org/Person">
  <span itemprop="name">John Doe</span>,
  <span itemprop="jobTitle">Sales Manager</span>
</div>
Run Code Online (Sandbox Code Playgroud)

我们如何将两个对象"组织"和"员工-1"链接在一起?

我尝试将以下子项添加到"employee-1"对象中

<meta itemprop="worksFor" itemscope itemtype="http://schema.org/Organization" itemref="organization">
Run Code Online (Sandbox Code Playgroud)

但这不起作用(至少在谷歌的结构化数据测试工具中没有).

itemref在这种情况下,如何正确使用微数据属性?

为了清楚起见,我还尝试了以下方法:

  • 添加itemprop="worksFor"到"组织"对象.
  • 添加itemref="organization"到"员工"对象.

所以

<div id="organization" itemprop="worksFor" itemscope itemtype="http://schema.org/Organization">
  <span itemprop="name">Sun Industries</span>,
  ...
</div>
...
<div id="employee-1" itemscope itemtype="http://schema.org/Person" itemref="organization">
  <span itemprop="name">John Doe</span>,
  <span itemprop="jobTitle">Sales …
Run Code Online (Sandbox Code Playgroud)

html5 reference microdata

19
推荐指数
2
解决办法
1万
查看次数

标签 统计

html5 ×1

microdata ×1

reference ×1