允许 Enyo 中工具提示的 HTML 内容
Allow HTML content for ToolTip in Enyo
我正在处理工具提示,我的要求是当用户将鼠标悬停在某个图标按钮上时,在工具提示中逐行显示更多详细信息。目前,我正在尝试这样:
{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."}
]
}
但这是将 HTML 内容视为字符串。我试图动态设置,但结果是一样的。低于我的尝试:
this.$.info.setContent('Fare Charges'+ "<span style='border:1px solid'"+flightsData[0].price+'</span><br>'+'<span>Some more data</span>');
有什么方法可以实现吗?
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);
您还需要覆盖 .moon-tooltip-label CSS class:
.moon-tooltip-label {
height:auto;
}
我正在处理工具提示,我的要求是当用户将鼠标悬停在某个图标按钮上时,在工具提示中逐行显示更多详细信息。目前,我正在尝试这样:
{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."}
]
}
但这是将 HTML 内容视为字符串。我试图动态设置,但结果是一样的。低于我的尝试:
this.$.info.setContent('Fare Charges'+ "<span style='border:1px solid'"+flightsData[0].price+'</span><br>'+'<span>Some more data</span>');
有什么方法可以实现吗?
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);
您还需要覆盖 .moon-tooltip-label CSS class:
.moon-tooltip-label {
height:auto;
}