Javascript 无法读取属性';HTML';未定义的
我在Angular 2.0 RC4中得到了这个奇怪的错误Javascript 无法读取属性';HTML';未定义的,javascript,angularjs,angular,typescript,undefined,Javascript,Angularjs,Angular,Typescript,Undefined,我在Angular 2.0 RC4中得到了这个奇怪的错误 Cannot read property 'HTML' of undefined index.html <!doctype html> <html> <head> <meta charset="utf-8"> <title>My th</title> <base href="/"> {{#unless environment.produ
Cannot read property 'HTML' of undefined
index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>My th</title>
<base href="/">
{{#unless environment.production}}
<script src="/ember-cli-live-reload.js" type="text/javascript"></script>
{{/unless}}
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="vendor/bootstrap/dist/css/bootstrap.min.css">
</head>
<body>
<div class="wrapper">
<div id="ihc" class="navbar navbar-fixed-top brand">
<div class="navbar-inner">
<div class="container-fluid">
<div class="nav-collapse collapse"></div>
</div>
</div>
</div>
<div class="body-content">
<my-app>Loading...</my-app>
</div>
</div>
{{#each scripts.polyfills}}<script src="{{.}}"></script>{{/each}}
<script src="vendor/ng2-bootstrap/bundles/ng2-bootstrap.min.js"></script>
<script>
System.import('system-config.js').then(function () {
System.import('main');
}).catch(console.error.bind(console));
</script>
<script src="vendor/ng2-bootstrap/bundles/ng2-bootstrap.min.js"></script>
</body>
</html>
这里是来自开发人员控制台的异常
zone.js:461 Unhandled Promise rejection: TypeError: Cannot read property 'HTML' of undefined
at Object.eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:29:47)
at eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:59:4)
at eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:60:3)
at Object.eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_element_schema_registry.js:18:29)
Evaluating http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js
Evaluating http://localhost:4200/vendor/@angular/compiler/src/schema/dom_element_schema_registry.js
Evaluating http://localhost:4200/vendor/@angular/compiler/src/compiler.js
Evaluating http://localhost:4200/vendor/@angular/compiler/compiler.js
Evaluating http://localhost:4200/vendor/@angular/compiler/index.js
Evaluating http://localhost:4200/vendor/@angular/platform-browser-dynamic/index.js
Evaluating http://localhost:4200/main.js
Error loading http://localhost:4200/main.js ; Zone: <root> ; Task: Promise.then ; Value: Error: TypeError: Cannot read property 'HTML' of undefined(…)
zone.js:463 Error: Uncaught (in promise): Error: TypeError: Cannot read property 'HTML' of undefined
at Object.eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:29:47)
at eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:59:4)
at eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:60:3)
at Object.eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_element_schema_registry.js:18:29)
Evaluating http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js
Evaluating http://localhost:4200/vendor/@angular/compiler/src/schema/dom_element_schema_registry.js
Evaluating http://localhost:4200/vendor/@angular/compiler/src/compiler.js
Evaluating http://localhost:4200/vendor/@angular/compiler/compiler.js
Evaluating http://localhost:4200/vendor/@angular/compiler/index.js
Evaluating http://localhost:4200/vendor/@angular/platform-browser-dynamic/index.js
Evaluating http://localhost:4200/main.js
Error loading http://localhost:4200/main.js
at Object.eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:29:47)
at eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:59:4)
at eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:60:3)
at Object.eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_element_schema_registry.js:18:29)
Evaluating http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js
Evaluating http://localhost:4200/vendor/@angular/compiler/src/schema/dom_element_schema_registry.js
Evaluating http://localhost:4200/vendor/@angular/compiler/src/compiler.js
Evaluating http://localhost:4200/vendor/@angular/compiler/compiler.js
Evaluating http://localhost:4200/vendor/@angular/compiler/index.js
Evaluating http://localhost:4200/vendor/@angular/platform-browser-dynamic/index.js
Evaluating http://localhost:4200/main.js
Error loading http://localhost:4200/main.js
at resolvePromise (http://localhost:4200/vendor/zone.js/dist/zone.js:538:32)
at resolvePromise (http://localhost:4200/vendor/zone.js/dist/zone.js:523:18)
at http://localhost:4200/vendor/zone.js/dist/zone.js:571:18
at ZoneDelegate.invokeTask (http://localhost:4200/vendor/zone.js/dist/zone.js:356:38)
at Zone.runTask (http://localhost:4200/vendor/zone.js/dist/zone.js:256:48)
at drainMicroTaskQueue (http://localhost:4200/vendor/zone.js/dist/zone.js:474:36)
at XMLHttpRequest.ZoneTask.invoke (http://localhost:4200/vendor/zone.js/dist/zone.js:426:22)consoleError @ zone.js:463_loop_1 @ zone.js:490drainMicroTaskQueue @ zone.js:494ZoneTask.invoke @ zone.js:426
zone.js:461未处理的承诺拒绝:TypeError:无法读取未定义的属性“HTML”
在Object.eval(http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:29:47)
评估时(http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:59:4)
评估时(http://localhost:4200/vendor/@angular/compiler/src/schema/dom\u security\u schema.js:60:3)
在Object.eval(http://localhost:4200/vendor/@angular/compiler/src/schema/dom_element_schema_registry.js:18:29)
评价http://localhost:4200/vendor/@angular/compiler/src/schema/dom\u security\u schema.js
评价http://localhost:4200/vendor/@angular/compiler/src/schema/dom\u element\u schema\u registry.js
评价http://localhost:4200/vendor/@angular/compiler/src/compiler.js
评价http://localhost:4200/vendor/@angular/compiler/compiler.js
评价http://localhost:4200/vendor/@angular/compiler/index.js
评价http://localhost:4200/vendor/@角度/平台浏览器动态/index.js
评价http://localhost:4200/main.js
加载错误http://localhost:4200/main.js ; 区域:;任务:承诺;值:错误:类型错误:无法读取未定义(…)的属性“HTML”
zone.js:463错误:未捕获(承诺中):错误:TypeError:无法读取未定义的属性“HTML”
在Object.eval(http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:29:47)
评估时(http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:59:4)
评估时(http://localhost:4200/vendor/@angular/compiler/src/schema/dom\u security\u schema.js:60:3)
在Object.eval(http://localhost:4200/vendor/@angular/compiler/src/schema/dom_element_schema_registry.js:18:29)
评价http://localhost:4200/vendor/@angular/compiler/src/schema/dom\u security\u schema.js
评价http://localhost:4200/vendor/@angular/compiler/src/schema/dom\u element\u schema\u registry.js
评价http://localhost:4200/vendor/@angular/compiler/src/compiler.js
评价http://localhost:4200/vendor/@angular/compiler/compiler.js
评价http://localhost:4200/vendor/@angular/compiler/index.js
评价http://localhost:4200/vendor/@角度/平台浏览器动态/index.js
评价http://localhost:4200/main.js
加载错误http://localhost:4200/main.js
在Object.eval(http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:29:47)
评估时(http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:59:4)
评估时(http://localhost:4200/vendor/@angular/compiler/src/schema/dom\u security\u schema.js:60:3)
在Object.eval(http://localhost:4200/vendor/@angular/compiler/src/schema/dom_element_schema_registry.js:18:29)
评价http://localhost:4200/vendor/@angular/compiler/src/schema/dom\u security\u schema.js
评价http://localhost:4200/vendor/@angular/compiler/src/schema/dom\u element\u schema\u registry.js
评价http://localhost:4200/vendor/@angular/compiler/src/compiler.js
评价http://localhost:4200/vendor/@angular/compiler/compiler.js
评价http://localhost:4200/vendor/@angular/compiler/index.js
评价http://localhost:4200/vendor/@角度/平台浏览器动态/index.js
评价http://localhost:4200/main.js
加载错误http://localhost:4200/main.js
允诺(http://localhost:4200/vendor/zone.js/dist/zone.js:538:32)
允诺(http://localhost:4200/vendor/zone.js/dist/zone.js:523:18)
在http://localhost:4200/vendor/zone.js/dist/zone.js:571:18
在ZoneDelegate.invokeTask(http://localhost:4200/vendor/zone.js/dist/zone.js:356:38)
在Zone.runTask(http://localhost:4200/vendor/zone.js/dist/zone.js:256:48)
在drainMicroTaskQueue(http://localhost:4200/vendor/zone.js/dist/zone.js:474:36)
在XMLHttpRequest.ZoneTask.invoke(http://localhost:4200/vendor/zone.js/dist/zone.js:426:22)consoleError@zone.js:463_loop_1@zone.js:490drainMicroTaskQueue@zone.js:494ZoneTask.invoke@zone.js:426
我绞尽脑汁想知道如何解决这个问题。这个错误通常是因为Angular2找不到您声明的脚本。它不是返回javascript,而是返回html(通常是索引页)
您需要做的是在抛出错误的页面上打开dev tools,然后查看network选项卡。检查每个文件并检查响应。其中一个脚本很可能返回html而不是javascript,因为您的路径不正确或文件丢失。有人能解释为什么这会被否决吗?这是一个合理的问题。
zone.js:461 Unhandled Promise rejection: TypeError: Cannot read property 'HTML' of undefined
at Object.eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:29:47)
at eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:59:4)
at eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:60:3)
at Object.eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_element_schema_registry.js:18:29)
Evaluating http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js
Evaluating http://localhost:4200/vendor/@angular/compiler/src/schema/dom_element_schema_registry.js
Evaluating http://localhost:4200/vendor/@angular/compiler/src/compiler.js
Evaluating http://localhost:4200/vendor/@angular/compiler/compiler.js
Evaluating http://localhost:4200/vendor/@angular/compiler/index.js
Evaluating http://localhost:4200/vendor/@angular/platform-browser-dynamic/index.js
Evaluating http://localhost:4200/main.js
Error loading http://localhost:4200/main.js ; Zone: <root> ; Task: Promise.then ; Value: Error: TypeError: Cannot read property 'HTML' of undefined(…)
zone.js:463 Error: Uncaught (in promise): Error: TypeError: Cannot read property 'HTML' of undefined
at Object.eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:29:47)
at eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:59:4)
at eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:60:3)
at Object.eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_element_schema_registry.js:18:29)
Evaluating http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js
Evaluating http://localhost:4200/vendor/@angular/compiler/src/schema/dom_element_schema_registry.js
Evaluating http://localhost:4200/vendor/@angular/compiler/src/compiler.js
Evaluating http://localhost:4200/vendor/@angular/compiler/compiler.js
Evaluating http://localhost:4200/vendor/@angular/compiler/index.js
Evaluating http://localhost:4200/vendor/@angular/platform-browser-dynamic/index.js
Evaluating http://localhost:4200/main.js
Error loading http://localhost:4200/main.js
at Object.eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:29:47)
at eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:59:4)
at eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js:60:3)
at Object.eval (http://localhost:4200/vendor/@angular/compiler/src/schema/dom_element_schema_registry.js:18:29)
Evaluating http://localhost:4200/vendor/@angular/compiler/src/schema/dom_security_schema.js
Evaluating http://localhost:4200/vendor/@angular/compiler/src/schema/dom_element_schema_registry.js
Evaluating http://localhost:4200/vendor/@angular/compiler/src/compiler.js
Evaluating http://localhost:4200/vendor/@angular/compiler/compiler.js
Evaluating http://localhost:4200/vendor/@angular/compiler/index.js
Evaluating http://localhost:4200/vendor/@angular/platform-browser-dynamic/index.js
Evaluating http://localhost:4200/main.js
Error loading http://localhost:4200/main.js
at resolvePromise (http://localhost:4200/vendor/zone.js/dist/zone.js:538:32)
at resolvePromise (http://localhost:4200/vendor/zone.js/dist/zone.js:523:18)
at http://localhost:4200/vendor/zone.js/dist/zone.js:571:18
at ZoneDelegate.invokeTask (http://localhost:4200/vendor/zone.js/dist/zone.js:356:38)
at Zone.runTask (http://localhost:4200/vendor/zone.js/dist/zone.js:256:48)
at drainMicroTaskQueue (http://localhost:4200/vendor/zone.js/dist/zone.js:474:36)
at XMLHttpRequest.ZoneTask.invoke (http://localhost:4200/vendor/zone.js/dist/zone.js:426:22)consoleError @ zone.js:463_loop_1 @ zone.js:490drainMicroTaskQueue @ zone.js:494ZoneTask.invoke @ zone.js:426