简体   繁体   English

在Enyo中允许ToolTip的HTML内容

[英]Allow HTML content for ToolTip in Enyo

I am working on Tooltip, where my requirement is to show more details line by line inside tooltip, when user hovers over some iconbutton. 我正在使用工具提示,当用户将鼠标悬停在某个图标按钮上时,我的要求是在工具提示中逐行显示更多详细信息。 Currently, I am trying like this: 目前,我正在尝试这样:

{kind: "moon.TooltipDecorator", components: [
                    {kind: "moon.IconButton", src: "$lib/moonstone/samples/assets/icon-button-enyo-logo.png"},
                    {kind: "moon.Tooltip", name:'info', floating: true, contentUpperCase: false,allowHtml: true, content: "Floating tooltip <br>for an IconButton."}
                ]
}

But this is treating HTML content just like strings. 但这就像对待字符串一样对待HTML内容。 I tried to set dynamically, but result is same. 我尝试动态设置,但结果相同。 Below what i tried: 下面我试过了:

this.$.info.setContent('Fare Charges'+ "<span style='border:1px solid'"+flightsData[0].price+'</span><br>'+'<span>Some more data</span>');

Is there any ways to achieve it? 有什么方法可以实现?

moon.Tooltip was designed to only be a single line of text. moon.Tooltip设计为仅一行文本。 If you want more than one line, you can create your own tooltip based off of moon.Tooltip. 如果您需要多条线,则可以基于moon.Tooltip创建自己的工具提示。

enyo.kind({
    name: 'my.Tooltip',
    kind: 'moon.Tooltip',
    published: {
        allowHtml: false
    },

    allowHtmlChanged: function() {
        this.$.client.set('allowHtml', this.allowHtml);
    },

    create: function () {
        this.inherited(arguments);
        this.allowHtmlChanged();
    },

});

enyo.kind({
    name: "App",
    components: [
        {kind: "moon.TooltipDecorator", components: [
                    {kind: "moon.IconButton", src:   "$lib/moonstone/samples/assets/icon-button-enyo-logo.png"},
                    {kind: "my.Tooltip", name:'info', floating: true, contentUpperCase: false, allowHtml: true, content: "Floating tooltip <br>for an IconButton."}
                ]
        }
     ]
});

new App().renderInto(document.body);

You also need to override the .moon-tooltip-label CSS class: 您还需要覆盖.moon-tooltip-label CSS类:

.moon-tooltip-label {
    height:auto;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM