那里,
我需要能够动态地改变按钮的不同状态(正常,悬停,按下)的背景颜色.
到目前为止我想出的是以下内容:http: //jsfiddle.net/suamikim/c3eHh/
Ext.onReady(function() {
function updateBackground() {
var theWin = win || this, // neccessary because of the call from the afterrender-event
btn = theWin.down('#btnTest'),
bckgr = theWin.down('#btnBckgr').getValue(),
bckgrHover = theWin.down('#btnBckgrHover').getValue(),
bckgrPressed = theWin.down('#btnBckgrPressed').getValue();
// Set normal background as button-style
// Should be ok
$('#' + btn.id).css('background', bckgr);
// Toggle background when hover-state changes
// Are there any downsides if this function gets called everytime the updateBackground-method is called? Do i have to dispose anything before …Run Code Online (Sandbox Code Playgroud) 我有一些服务,我的应用程序中的许多类使用.例如,这可以是LoggerService将消息记录到内部存储并将其打印到控制台的示例.
这项服务看起来像这样:
export class LoggerService {
let _logs = [];
addLog(msg) {
this._logs.push(msg);
console.log(this._logs.length + ': ' + msg);
}
}
Run Code Online (Sandbox Code Playgroud)
我想在Aurelia中通常的方法是使用这个带有依赖注入的类,因为它默认使用单例,因此工作得很好.然后,示例用法可能如下所示:
import {autoinject, Aurelia} from 'aurelia-framework';
import {LoggerService} from 'LoggerService';
@autoinject
export class SomeViewModel {
let _loggerService;
constructor(loggerService) {
this._loggerService = loggerService
}
somethingChanged() {
this._loggerService.addLog('Something changed...');
}
}
Run Code Online (Sandbox Code Playgroud)
基本上这种方法工作得很好但是在更大的范围内感觉有点"笨拙",我希望它可以简化:
MyNamespace.LoggerService.addLog('blahblah');直接从命令行调用代码.我如何通过Aurelia实现这一目标?有没有更直接的方法,这也可以从命令行给我一个更好的调试体验?
是否可以使用装饰器通过一些自定义信息来标记接口的某些属性?
最好用一个例子解释一下:
应用状态界面:
export interface AppState {
@persist userData: UserData,
@persist selectedCompany: UserCompany,
// userCompanies should not be persisted since they are always
// fetched afresh from the server...
userCompanies: UserCompany[]
}
Run Code Online (Sandbox Code Playgroud)
保留所有相关状态信息的方法:
persistState(state) {
let newState = {};
Object.keys(state).forEach((key) => {
if (state[key] is decorated with @persist) {
newState[key] = state[key];
}
});
// Persist newState...
}
Run Code Online (Sandbox Code Playgroud)
这可能吗?
如果是这样,我将非常感谢您提供一些资源来指出正确的方向!
如果没有,有没有其他优雅的选择?
我们在 上运行服务our-site.com。我们的客户可以通过简单地从 链接their-site.com到our-site.com/customer-service或通过 iFrame 将我们的服务嵌入到their-site.com. 想象一下直接访问 GMap 与看到它嵌入在 IFrame 中。
从 Chrome 80(我猜)开始,当服务在 iFrame 内运行时,我们的 Google Analytics 停止工作。Chrome 给了我这个(很清楚)的信息:
与http://our-site.com/上的跨站点资源关联的 cookie设置为没有该
SameSite属性。它已被阻止,因为 Chrome 现在仅在设置了SameSite=None和 的情况下才提供具有跨站点请求的 cookieSecure。您可以在应用程序>存储>Cookies 下的开发人员工具中查看 cookie,并在https://www.chromestatus.com/feature/5088147346030592和https://www.chromestatus.com/feature/5633521622188032 上查看更多详细信息。
此外,如果我their-site.com使用our-site.com/customer-service嵌入在 iFrame 中的方式访问,我在 GA 实时概览中看不到任何内容。
如果我手动禁用2层的功能same-site-by-default-cookies和cookies-without-same-site-must-be-secure在chrome://flags和访问their-site.com与our-site.com/customer-service嵌入的iFrame我看到在GA实时概览页面访问。
当直接访问our-site.com/customer-serviceGA 时仍然正常工作:
前段时间我遇到了一个问题,当我的 ExtJS 5 应用程序嵌入到 IFrame 中时,触摸设备上的滚动不再起作用(请参阅此线程)。
我已经通过覆盖 Ext 框架中的一些内容解决了这个问题(请参阅解决方案)。
解决方案的一个步骤是将touchmove事件分派给文档本身(框架阻止默认处理此事件):
// ...
touchmove: function(e) {
window.document.dispatchEvent(e.event);
}
// ...
Run Code Online (Sandbox Code Playgroud)
尽管这个解决方案基本上有效,但它有一个缺陷:调度事件会InvalidStateError在每个touchmove事件上抛出一个未处理的事件,这显然很常见:
如果我只是在dispatchEvent语句周围放置一个 try/catch ,则在触摸设备上的 IFrame 内滚动不再起作用,就好像根本没有调用它一样。
如何在不再次中断滚动的情况下摆脱错误?
可以在此处测试滚动有效但发生许多未处理错误的 Testapp 。