Javascript 使用HTML5数据的Jquery声明方式-*
您知道以声明方式使用Jquery的方法吗 你们中的一些人会告诉我使用AngularJS,但是没有更轻量级的东西,只有视图端(因为我使用的是Symfony,所以不需要路由和复杂的功能) 是否有一个框架或库可以取代(我知道这是一种不好的做法,但这只是一个例子):Javascript 使用HTML5数据的Jquery声明方式-*,javascript,jquery,angularjs,html,Javascript,Jquery,Angularjs,Html,您知道以声明方式使用Jquery的方法吗 你们中的一些人会告诉我使用AngularJS,但是没有更轻量级的东西,只有视图端(因为我使用的是Symfony,所以不需要路由和复杂的功能) 是否有一个框架或库可以取代(我知道这是一种不好的做法,但这只是一个例子): 点击我 作者: <any data-xx-event="click" data-xx-action="..."> </any> 你只是想这么做吗 摘自页面: 目标: <hangout-module>
点击我
作者:
<any data-xx-event="click" data-xx-action="..."> </any>
你只是想这么做吗
摘自页面:
目标:
<hangout-module>
<hangout-chat from="Paul, Addy">
<hangout-discussion>
<hangout-message from="Paul" profile="profile.png"
profile="118075919496626375791" datetime="2013-07-17T12:02">
<p>Feelin' this Web Components thing.</p>
<p>Heard of it?</p>
</hangout-message>
</hangout-discussion>
</hangout-chat>
<hangout-chat>...</hangout-chat>
</hangout-module>
在查看了最流行的github js存储库(>300星)之后,我发现以下库/框架可以满足以下约束:
- 使用data-*绑定js
- 与Jquery打交道
- 有强大的社区支持
- 理想情况下,可以使用在不引人注目的方式,但我不是100%肯定这一点
- 淘汰赛()-Github上的5457*颗星
- 主干网+环氧树脂.js()-477*Github上的星星
- Rivets.js()-Github上的1820*颗星
- 中冷器.js()-372*Github上的星星
据我所知,Knockout有很好的文档记录,是开始使用JS框架/库的良好开端。Hi,检查knockoutjsHello,是的,这是我在TodoMVC的候选名单上看到的,但我不确定这是最简单/最简单的事情,因为它提供了大量功能:-)你好,谢谢你的回答,但我更多的是在寻找类似于淘汰赛JSIS Xavier13的答案你想要什么?
<hangout-module>
<hangout-chat from="Paul, Addy">
<hangout-discussion>
<hangout-message from="Paul" profile="profile.png"
profile="118075919496626375791" datetime="2013-07-17T12:02">
<p>Feelin' this Web Components thing.</p>
<p>Heard of it?</p>
</hangout-message>
</hangout-discussion>
</hangout-chat>
<hangout-chat>...</hangout-chat>
</hangout-module>
var XFooProto = Object.create(HTMLElement.prototype);
// 1. Give x-foo a foo() method.
XFooProto.foo = function() {
alert('foo() called');
};
// 2. Define a property read-only "bar".
Object.defineProperty(XFooProto, "bar", {value: 5});
// 3. Register x-foo's definition.
var XFoo = document.registerElement('x-foo', {prototype: XFooProto});
// 4. Instantiate an x-foo.
var xfoo = document.createElement('x-foo');
// 5. Add it to the page.
document.body.appendChild(xfoo);