我通过使用 decoratePluginOutlet 然后遍历层级结构来查找徽章中的类别链接并将其添加到主题 div 中,最终获得了类别 ID。有没有更好的方法来做到这一点?
api.decoratePluginOutlet(
"full-page-search-category",
(elem, args) => {
let searchCategory = elem.parentElement.parentElement
let fpsTopic = searchCategory.parentElement.parentElement
let category_id = searchCategory.children[0].getAttribute('href').split("/").slice(-1);
console.log(category_id)
fpsTopic.classList.add("category_" + category_id)
}
);