我有一个类型:
type tSelectProtected = {
handleSelector?: string,
data?: tSelectDataItem[],
wrapperEle?: HTMLElement,
inputEle?: HTMLElement,
listEle?: HTMLElement,
resultEle?: HTMLElement,
maxVisibleListItems?: number
}
Run Code Online (Sandbox Code Playgroud)
我宣布一个全局模块明智的变量:
var $protected : tSelectProtected = {};
Run Code Online (Sandbox Code Playgroud)
我在function1范围内分配了适当的值:
$protected.listEle = document.createElement('DIV');
Run Code Online (Sandbox Code Playgroud)
我稍后在function2范围内调用:
$protected.listEle.classList.add('visible');
Run Code Online (Sandbox Code Playgroud)
我收到TypeScript错误:
error TS2533: Object is possibly 'null' or 'undefined'
Run Code Online (Sandbox Code Playgroud)
我知道我可以使用显式检查type来平息编译器,但对于大多数非平凡的情况,这似乎是非常不方便的.
如何在不禁用TS编译器检查的情况下处理这种情况?
1 -什么是WebKit的语法是否正确(主要为Safari浏览器在iPad上,好,如果它工作在Win Chrome)登录.addEventListener到hashChange事件?
2 - 是否可以(和如何)通过.dispatchEvent上述浏览器手动/编程调度hashChange事件?
TIA.
我找到了1的答案:
window.addEventListener("hashchange", function() {console.log(location.hash)});
但我仍然不知道如何发送hashchange手册,因为我不知道EVENTOBJECT应该传递给谁window.dispatchEvent(EVENTOBJECT).
我需要一些帮助.我正在使用Angular2和TypeScript的基础知识作为我从A1切换到A2的一部分,所以这里的内容对你来说可能是显而易见的.
我有这种情况:
AppConfigConst 拥有一些静态的app宽配置数据.AppConfigurationInjectable采用AppConfigConst并公开简单的API来访问配置数据.SelectedLanguageInjectable想要使用方法从AppConfigConst这里得到这个:ERROR在[默认] C:_DEV\XXX\src\app\shared\selected-language\selected-language.injectable.ts:9:46属性'getSupportedUiLanguages'在类型'typeof AppConfigurationInjectable'上不存在.
我对http://getsymphony.com和http://symfony.com/网站感到困惑.我正在寻找可以开始学习Symfony框架的地方,我不知道http://getsymphony.com网站是否有任何对Symfony框架的引用,或者这对于未知CMS来说只是一个棘手的名称.有人可以解释一下吗?