- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 humane.js与 aurelia但是我遇到了问题。
看来 humane.js 在创建时向 DOM 添加了一个元素,到目前为止我发现的唯一方法就是像这样强制它......
showMessage(message) {
this.notify = humane.create();
this.notify.log(message);
}
但是,每次调用 showMessage() 时,都会创建一个新的 humane 实例。这会破坏队列,因为每个队列都是单独渲染的。
我尝试将 create()
放入 View 模型的 activate()
方法中,但这似乎也不起作用。
有什么想法吗?
最佳答案
这解决了问题,我创建了一个人性化的自定义元素,然后将其包含在 app.html 中,就像加载指示器在骨架应用程序中一样。
import humane from 'humane-js';
import 'humane-js/themes/original.css!';
import {inject, noView} from 'aurelia-framework';
import { EventAggregator } from 'aurelia-event-aggregator';
import { ApiStatus } from 'resources/messages';
@noView
@inject(EventAggregator)
export class StatusIndicator {
constructor(ea) {
this.ea = ea;
ea.subscribe(ApiStatus, msg => this.showMessage(msg.apistatus));
}
attached() {
this.humane = humane.create();
}
showMessage(message) {
this.humane.log(message);
}
}
重要的部分是attached()
,它允许人性化的设置正确工作。
关于aurelia - 将 humane.js 与 aurelia 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30824375/
我们想利用 Humanizer package (因为我们在其他地方使用它)并且不想添加更多类似的库或手工代码。 我有一些时间跨度,其中一些是数千天。我想将它们人性化并将它们转换为年份。现在我很欣赏一
public class Human implements Comparable { private int age; private String name; public
我无法从 Homecontrollers 操作方法调用新的 Human 对象。 var employee = new Human { id = 1, name = "home inde
内置的 .Net 方法 TextInfo.ToTitleCase 可以很好地处理法语句子,但有些示例会导致问题,请参阅 remarks (复制如下): Generally, title casing
为了好玩,我制作了这个牌组洗牌功能来模仿人们如何不完美地洗牌。他们将其切成近两半,并使用“褶边”方法将左右甲板交织在一起,然后重复此过程任意多次。甲板永远不会完美地编织在一起。您可以将它们打乱,如 L
我有一款在线角色扮演游戏,我很认真地对待它。最近我遇到了用户使用假名制作假字符的问题,只是一堆不同的字母。就像 Ghytjrhfsdjfnsdms、Yiiiedawdmnwe、Hhhhhhhhhhej
我正在寻找一种算法,该算法可以告诉我照片/网络摄像头实时Feed上的眼睛在哪里。 我已经进行了很多搜索,但是现在我不想从很多复杂性入手。 只是为了好玩而已。我的想法是要采用某种方法来接收图像并返回与用
为了防止对我的 django 站点的 DOS 类型的攻击,我正在考虑显示一个验证码页面,如果我的网络应用程序经常受到某个 IP 的攻击。类似于当你表现出过多的事件时 SO 正在做的事情。 在 Djan
我正在使用此代码将字节转换为更易读的格式,例如155K, 1.5M, 1.5G,但是从CPAN上的解释看不出转换后的值如何打印到小数点后第二位并四舍五入。谢谢。 use strict; use war
我最近尝试过Humanizer.Js 。我从 here 添加了相同的 nuget 引用,并将其添加到我的页面中,名称为 。但是在我的页面加载中我收到错误:“未捕获类型错误:无法读取未定义的属性‘原型
我正在开发一个 Django 应用程序,它有 LANGUAGE_CODE设置为es西类牙语。 我正在尝试格式化数字在模板中的呈现方式。现在它们呈现为: S/ 18,00当S/ 18.00需要。 我搜索
class Address { private enum Component { NUMBER, STREET, STATE, COUNTRY } pr
我已经成功地使用 Humanizer 将英语单词单数化/复数化, 但当我将 CultureInfo 设置为意大利语时,它只会向单词添加一个额外的“s”。 例如: "Man".Pluralize() =
是否有一个 shell 命令可以简单地在以字节为单位的数字字符串和某些命令通过 -h 提供的“人类可读”的数字字符串之间来回转换选项? 澄清问题:ls -l没有 -h选项(某些输出被抑制) > ls
我已经学习ANTLR几天了。我学习它的目标是我将能够生成解析器和词法分析器,然后亲自将它们从 Java 手动翻译成我的目标语言(C/C++/Java/C#/Python,没有工具支持它)。我选择 AN
我正在使用 Python Humanize module 来格式化一些文件大小信息。该模块默认保留一位小数,有没有办法返回具有不同小数位的值? 这是默认值: >>> humanize.naturals
我想在模板之外使用django.contrib. humanize,实际上是在模型内部使用来人性化一些短信中的某些日期。 这可能吗?我怎样才能做到这一点? 最佳答案 您可以导入模型中的函数: from
PAYCODE_BLUEPAY = "BLUEPAY" PAYCODE_HEARTLAND = "HEARTLAND" PAYCODE_1STPAY = "1STPAYMENT" PAYCODE_CH
希望实现按功能排名/排序,按照我们人类认为相关的方式对产品进行排名,而不是计算机认为相关的方式。目前我有这个sql语句 select MATCH(productName) AGAINST('xyz'
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 7年前关闭。 Improve this qu
我是一名优秀的程序员,十分优秀!