您是否知道以声明方式使用Jquery的方法?
有些人会告诉我使用AngularJS,但是没有更轻量级的东西,只有视图方面(不需要路由和复杂功能,因为我使用Symfony)
是否有一个替换的框架或库(我知道它的不良做法,但它的例子):
<button onclick="myFunction()">Click me</button>
按:
<any data-xx-event="click" data-xx-action="..."> </any>
答案 0 :(得分:0)
您是否只是尝试register new HTML elements?
从页面中提取:
目标:
<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);
答案 1 :(得分:0)
在回顾了最受欢迎的github js存储库(&gt; 300星)后,我发现以下lib / frameworks可以满足以下约束条件:
列表是:
*截至2014年9月21日。
从我所见,Knockout有很好的文档记录,是开始使用JS框架/库的良好开端。