可以更改下拉列表的名称吗?

这个解决方案令人印象深刻,但你可以这样做 @Don:

api
  .modifySelectKit("category-drop")
  .replaceContent((component, content) => {
    let newContent = [];
    content.forEach((item) => {
      if (
        component.category?.slug === "general" &&
        item.id === "all-categories"
      ) {
        item.name = "jojo";
      }

      newContent.push(item);
    });
    return newContent;
  });

https://github.com/discourse/discourse/blob/main/app/assets/javascripts/select-kit/addon/mixins/plugin-api.js 列出了你可以执行的所有操作:

  • appendContent
  • prependContent
  • replaceContent
  • onChange

如果你在使用过程中遇到任何问题,请告诉我。这应该会有更好的文档记录,但如果你有任何疑问,我随时都在。