我是Mithril JS框架的新手,我喜欢它的渲染性能.轻巧是一个加号,但我想使用jQuery UI,以便可以从其某些功能(例如可拖动的交互)中受益.据我了解,jQuery UI和Mithril都可以操作DOM元素.如果是这样,将jQuery UI与Mithril一起使用有多实用?
I am new to the Mithril JS framework and I love its rendering performance. It being light-weight is a plus, but I would like to use jQuery UI so that I can benefit from some of its functionality such as the draggable interaction. From my understanding, both jQuery UI and Mithril manipulate DOM elements. If so, how practical is it to use jQuery UI with Mithril?
推荐答案您的问题有点悬而未决,但要给出一个有用的答案:秘银模板实际上不会触及DOM,直到您调用m.render,m.module或m.route.完成后,差异引擎会根据需要创建或更新元素以镜像模板的结构.您可以在模板中使用config来获取真实的DOM元素,并在其上运行jQuery/jQuery UI:
Your question is a bit open ended, but to give a useful answer: Mithril templates don't actually touch the DOM until you call either m.render, m.module or m.route. When you do, the diff engine creates or updates elements as needed to mirror the structure of the template. You can use config in templates to get to real DOM elements, and run jQuery/jQuery UI on them:
function draggable(element, isInitialized) { if (!isInitialized) $(element).draggable() } var module = {} module.controller = function() { this.greeting = "Hello" } module.view = function(ctrl) { m("div", {config: draggable}, ctrl.greeting) } m.module(document.body, module)更多推荐
将jQuery UI函数与Mithril结合使用
发布评论