如何将图标放入 Kendo 菜单中?

How to put icons into a Kendo Menu?

我有以下 Kendo 菜单:

<div id="menu"></div>

<script>
    console.log("executes")
    $("#menu").kendoMenu({
        dataSource: [{
            text: "menu", icon: "k-icon k-i-more-horizontal", items: [
                { text: "Edit", spriteCssClass: "k-icon k-i-edit" },
                { text: "Delete", spriteCssClass: "k-icon k-i-delete" },
            ]
        }

        ]
    });
</script>

由于 spriteCssClass 不推荐 [https://www.telerik.com/forums/spritecssclass-is-not-working-with-icons-in-latest-version] ,我尝试了 icon:... 正如您在数据源的第一行中看到的那样。但这也行不通。

如何将 Kendo 一些图标放入 Kendo 菜单中?

我解决了这个问题,只需将 放入 text 并设置 encoded: false.

   $("#menu").kendoMenu({
        dataSource: [{
            text: "<span class=\"k-icon k-i-more-horizontal\"></span>", encoded: false, items: [
                { text: "<span class=\"k-icon k-i-edit\"></span><span>Edit</span>", encoded: false },
                { text: "<span class=\"k-icon k-i-delete\"></span><span>Delete</span>", encoded: false }
            ]
        }]
    });

您还可以在 Kendo UI 菜单中使用 FontAwesome 图标,如下文所述: