问题标签 [mithril.js]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
139 浏览

reactjs - Mithril VM DOM diffing 未检测到附加事件处理程序中的差异

这可能不是秘银特定的问题,但一般来说 VM DOM 不同。在“重绘”页面并附加新的事件处理程序、删除事件处理程序或更改与“onclick”等事件关联的事件处理程序时,似乎 VM DOM 差异不会检测到更改,我必须显式强制重新渲染“真实”DOM。

是否有一个很好的模式来处理这些情况。

0 投票
1 回答
363 浏览

mithril.js - m.request 发出太多请求

我刚开始学习秘银,我正在尝试编写一个与 RESTful API 交互的简单前端。但是,当我在浏览器中加载它时,浏览器每秒向“/posts”发出 < 30 个 GET 请求!我不确定这是否是我的代码中的错误或秘银如何工作......我怎样才能让 m.request 在整个代码中发出一次请求,或者任意更新 Post.list?

0 投票
2 回答
1017 浏览

javascript - Mithril.js 中大量元素的性能问题

到目前为止,我的应用程序有一个可排序和可过滤的列表以及一些输入和复选框。如果列表有超过 500 个项目,则会出现问题,然后每个带有用户输入的元素(复选框、输入字段、菜单)都会随着列表中项目数量的增加而延迟大约半秒。列表的排序和过滤完成得足够快,但输入元素的滞后时间太长。

问题是:列表和输入元素如何解耦?

这是列表代码:

这就是从应用程序主视图初始化列表和所有其他组件的方式:

我开始通过将 m.redraw.strategy("none") 和 m.startComputation/endComputation 添加到单击事件来解决问题,这解决了问题,但这是正确的解决方案吗?例如,如果我将来自第 3 方的 Mithril 组件与我的列表组件一起使用,我应该如何在不更改其代码的情况下为外部组件执行此操作?

另一方面,我的列表组件可以使用“保留”标志之类的东西吗?因此,除非被告知,否则默认情况下列表不会重绘?但第三方组件的问题也会持续存在。

我知道还有其他策略可以解决这个问题,比如列表的分页,但我想知道秘银方面的最佳实践是什么。

在此先感谢,斯特凡

0 投票
1 回答
910 浏览

mongodb - 我可以将 Mongodb 与 mithril js 或 vue js 一起使用吗?

我想了解如何将数据库(例如 Mongodb 或 MySql)连接到 mithril js 或 vue js。任何有用的链接或教程?谢谢

0 投票
1 回答
1057 浏览

javascript - 删除哈希时是否会触发 hashchange 事件?

我同时使用了 jquery hashchange 和 window.addEventListener("hashchange") 但是当哈希部分被代码删除时事件没有触发。我正在使用 mithril.js 更改哈希:

删除 url 的哈希部分时事件是否会触发?如果不是,处理这种情况的解决方法是什么?

0 投票
1 回答
71 浏览

javascript - alertify.alert 在秘银(m.request)响应中不起作用

我正在做一个项目,我正在使用mithril.js并在响应中使用alertify.js我想提醒一些数据它不起作用,如果我在 m.request 之前使用相同的警报它工作正常

0 投票
3 回答
784 浏览

javascript - Mithril doesnt auto redraw the view

When changing prop values mithril doesnt auto redraw the view, on press of a button i update my prop as:

it updates the prop value but doesn't reflect on view by using m.redraw() it works fine ?

0 投票
2 回答
101 浏览

javascript - react.js 中路由的工作原理

我正在做一个项目,我想在从 Ajax 成功登录后加载另一个组件或模块,我们可以用 react 来做吗

0 投票
1 回答
518 浏览

javascript - Mithriljs: prevent full application reload on submit

I have a single component which is just a login form. When login is unsuccessful I get a full application reload for some reason.

This is the application main entry. All it does is the initial authentication ping. If session is up it loads the actual application, otherwise it mounts Authentication component which is just a login form.

Below is the Authentication component minus the view. It binds login variables to the view and defines submit action. When I run submit action with incorrect credentials it reloads the application.

Why does it reload the application?? Chrome console says: Navigated to http://localhost:3000/? right after "Login Failure !!!" console message. This causes full application reload. So any on-screen error messages and popups about incorrect login simply disappear. It does print the last error message to the console "Login Failure !!!". After that, when submit function exits, it navigates to the root of the URL causing a full reload.

What am I doing wrong?

Thank you very much.

0 投票
1 回答
160 浏览

json - 在 localhost 上运行的 Sails 的历史和 XHR 问题

使用默认配置,如果我在 localhost 中运行它的 Sails 服务器,我将无法在我的 Mithril 应用程序中创建 XHR。我得到的是:

XMLHttpRequest 无法加载http://localhost:1337/json/test-realms.json。“Access-Control-Allow-Origin”标头包含无效值“”。因此,Origin 'null' 不允许访问。

如果我启用 CORSallRoutes: true, origin: '*'该问题就消失了,而是我得到:

DOMException:无法在“历史”上执行“replaceState”:无法在源为“null”的文档中创建URL 为“ http://localhost:1337/#!/ ”的历史状态对象。

这里的问题到底是什么?

更新:

  • 我正在sails lift用作服务器。
  • Web 应用程序通过http://test.pink. 域通过 HOSTS 文件设置为 LAN IP。
  • 没有资源通过file:///或加载localhost