我正在使用带有 Office Fabric 的枢轴控件。它是标准的 JS 库,而不是 React/Angular 库。如何使用 JS/JQuery 选择选项卡?
我在页面加载时调用 API,并且取决于我想要显示第一个选项卡或第三个选项卡的结果。
<div class="ms-Pivot">
<ul class="ms-Pivot-links">
<li class="ms-Pivot-link is-selected" data-content="files" title="My files" tabindex="1">
My files
</li>
<li class="ms-Pivot-link " data-content="recent" title="Recent" tabindex="1">
Recent
</li>
<li class="ms-Pivot-link " data-content="shared" title="Shared with me" tabindex="1">
Shared with me
</li>
<li class="ms-Pivot-link" tabindex="1">
<i class="ms-Pivot-ellipsis ms-Icon ms-Icon--More"></i>
</li>
</ul>
<div class="ms-Pivot-content" data-content="files">
This is the my files tab.
</div>
<div class="ms-Pivot-content" data-content="recent">
This is the recent tab.
</div>
<div class="ms-Pivot-content" data-content="shared">
This is the shared with me tab.
</div>
</div>
<script type="text/javascript">
var PivotElements = document.querySelectorAll(".ms-Pivot");
for (var i = 0; i < PivotElements.length; i++) {
new fabric['Pivot'](PivotElements[i]);
}
</script>
https://dev.office.com/fabric-js/Components/Pivot/Pivot.html