不打扰的淘汰赛 [英] Unobtrusive Knockout
问题描述
我最近适应了Knockout,我认为这是一个很棒的框架.但是我有一个担忧.
I've recently got up to speed with Knockout and I think it's a fantastic framework. However I have one concern.
我发现在非平凡的绑定情况下,我的Java代码片段爬到了我的视图(标记)中.实际上,Knockout文档中的很多代码示例也对此进行了演示.
I'm finding that in non-trivial binding cases, I have snippets of javascript code creeping into my view (markup). In fact quite a few code samples in the Knockout documentation demonstrate this too.
这会使淘汰赛本质上引人注目吗?
我是否应该接受它,而不是在实践中担心?
Should I just accept it for what it is and not be worried in practice?
或者我应该采用任何模式/技术来使淘汰赛变得不那么引人注目吗?
推荐答案
好问题.我已经写了一段时间的复杂的KnockoutJS视图,但是直到我切换到 Ryan Niemeyer的类绑定提供程序之前,我从未对此感到满意.一个>.
Great question. I've been writing complex KnockoutJS views for awhile and was never satisfied until I switched to Ryan Niemeyer's class binding provider.
Knockout ClassBindingProvider允许您在JavaScript对象中声明绑定,然后从data-class
属性引用它们,类似于CSS类的工作方式.效果很好!
The Knockout ClassBindingProvider allows you to declare your bindings in a JavaScript object and then reference them from a data-class
attribute similar to how css classes work. It works great!
请参见示例TodoMVC应用.
这篇关于不打扰的淘汰赛的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!