Knockout JS - 数据绑定到文字?
目前我有以下元素
<h6 class="header">
Chance of Precipitation: <span data-bind="text: PrecipitationLabel"></span>
</h6>
这工作正常,但在我的情况下我真的不需要跨度标签——可观察的仅加载用于显示,所以我不需要更新元素。我知道我可以绑定一个计算/因变量,将“Chance...”文本与 PrecipitationLabel 结合起来,但这会将一些静态标记从视图中删除,这并不理想。
是否有类似于 Razor 标签的东西可以仅输出文字?
Currently I have the following element
<h6 class="header">
Chance of Precipitation: <span data-bind="text: PrecipitationLabel"></span>
</h6>
This works fine, but I don't really need a span tag in my case --the observable only loads for display, so I don't need to update an element. I know I could bind with a computed/dependent variable that combines the "Chance..." text with PrecipitationLabel, but that takes some of the static markup out of the view, which is not ideal.
Is there something similar to Razor's tags to output just a literal?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在寻找的功能已11 天前添加到 github。语法为:
它尚未包含在任何已发布的下载中。
The functionality you are looking for was added to github 11 days ago. The syntax would be:
It is not yet included in any published download.
或者你可以用这个,
Or you may use this,