【问题标题】:Angular 4 RC.4 & .net core The selector "app" did not match any elementsAngular 4 RC.4 & .net core 选择器“app”不匹配任何元素
【发布时间】:2017-03-18 10:56:30
【问题描述】:

我有这个 https://github.com/damirkusar/AngularMeetsNetCore/tree/AngularRc4 项目,我在其中使用 Angular 4 RC.4 和 .net 核心。更新文件并通过热模块替换刷新应用程序时,出现以下错误:

Unhandled Promise rejection: The selector "app" did not match any elements ; Zone: <root> ; Task: Promise.then ; Value: ZoneAwareError__zone_symbol__error: Error: The selector "app" did not match any elements
    at DefaultDomRenderer2.selectRootElement (http://localhost:61234/dist/vendor.js:24029:19) [angular]
    at DebugRenderer2.selectRootElement (http://localhost:61234/dist/vendor.js:12878:49) [angular]
    at createElement (http://localhost:61234/dist/vendor.js:9171:23) [angular]
    at createViewNodes (http://localhost:61234/dist/vendor.js:11672:44) [angular]
    at createRootView (http://localhost:61234/dist/vendor.js:11619:5) [angular]
    at callWithDebugContext (http://localhost:61234/dist/vendor.js:12727:42) [angular]
    at Object.debugCreateRootView [as createRootView] (http://localhost:61234/dist/vendor.js:12204:12) [angular]
    at ComponentFactory_.create (http://localhost:61234/dist/vendor.js:9591:46) [angular]
    at ComponentFactoryBoundToModule.create (http://localhost:61234/dist/vendor.js:3490:29) [angular]
    at ApplicationRef_.bootstrap (http://localhost:61234/dist/vendor.js:5024:57) [angular]
    at http://localhost:61234/dist/vendor.js:4811:79 [angular]
    at Array.forEach (native) [angular]
    at PlatformRef_._moduleDoBootstrap (http://localhost:61234/dist/vendor.js:4811:42) [angular]
    at http://localhost:61234/dist/vendor.js:4772:27 [angular]__zone_symbol__message: "The selector "app" did not match any elements"__zone_symbol__stack: "Error: The selector "app" did not match any elements↵    at DefaultDomRenderer2.selectRootElement (http://localhost:61234/dist/vendor.js:24029:19) [angular]↵    at DebugRenderer2.selectRootElement (http://localhost:61234/dist/vendor.js:12878:49) [angular]↵    at createElement (http://localhost:61234/dist/vendor.js:9171:23) [angular]↵    at createViewNodes (http://localhost:61234/dist/vendor.js:11672:44) [angular]↵    at createRootView (http://localhost:61234/dist/vendor.js:11619:5) [angular]↵    at callWithDebugContext (http://localhost:61234/dist/vendor.js:12727:42) [angular]↵    at Object.debugCreateRootView [as createRootView] (http://localhost:61234/dist/vendor.js:12204:12) [angular]↵    at ComponentFactory_.create (http://localhost:61234/dist/vendor.js:9591:46) [angular]↵    at ComponentFactoryBoundToModule.create (http://localhost:61234/dist/vendor.js:3490:29) [angular]↵    at ApplicationRef_.bootstrap (http://localhost:61234/dist/vendor.js:5024:57) [angular]↵    at http://localhost:61234/dist/vendor.js:4811:79 [angular]↵    at Array.forEach (native) [angular]↵    at PlatformRef_._moduleDoBootstrap (http://localhost:61234/dist/vendor.js:4811:42) [angular]↵    at http://localhost:61234/dist/vendor.js:4772:27 [angular]"message: (...)name: (...)ngDebugContext: DebugContext_ngErrorLogger: ()originalStack: (...)stack: (...)toSource: ()toString: ()zoneAwareStack: (...)get message: ()set message: (value)get name: ()set name: (value)get originalStack: ()set originalStack: (value)get stack: ()set stack: (value)get zoneAwareStack: ()set zoneAwareStack: (value)__proto__: Object Error: The selector "app" did not match any elements
    at DefaultDomRenderer2.selectRootElement (http://localhost:61234/dist/vendor.js:24029:19) [angular]
    at DebugRenderer2.selectRootElement (http://localhost:61234/dist/vendor.js:12878:49) [angular]
    at createElement (http://localhost:61234/dist/vendor.js:9171:23) [angular]
    at createViewNodes (http://localhost:61234/dist/vendor.js:11672:44) [angular]
    at createRootView (http://localhost:61234/dist/vendor.js:11619:5) [angular]
    at callWithDebugContext (http://localhost:61234/dist/vendor.js:12727:42) [angular]
    at Object.debugCreateRootView [as createRootView] (http://localhost:61234/dist/vendor.js:12204:12) [angular]
    at ComponentFactory_.create (http://localhost:61234/dist/vendor.js:9591:46) [angular]
    at ComponentFactoryBoundToModule.create (http://localhost:61234/dist/vendor.js:3490:29) [angular]
    at ApplicationRef_.bootstrap (http://localhost:61234/dist/vendor.js:5024:57) [angular]
    at http://localhost:61234/dist/vendor.js:4811:79 [angular]
    at Array.forEach (native) [angular]
    at PlatformRef_._moduleDoBootstrap (http://localhost:61234/dist/vendor.js:4811:42) [angular]
    at http://localhost:61234/dist/vendor.js:4772:27 [angular]
consoleError @ vendor.js:100206

手动刷新应用时,它会正确加载和更新。

有谁知道问题出在哪里以及我必须改变什么? 感谢您的帮助。

【问题讨论】:

  • 您可能需要检查您的 package.json 并确保您的依赖项位于正确的(最新)版本上。具体来说,zone.js 到 0.8.4;打字稿到 2.2.1;可能还有其他人。这也可以纠正您其他问题中的问题。
  • 嗨@R.Richards,感谢您的提示,但这并没有解决问题。更新的包已签入。
  • 是的,你更新了它们。 :) 错误还是一样?那里没有变化?
  • 当我已经在更新它们时,认为更新它们是有意义的:)!是的,看起来像同样的错误:(

标签: angular webpack asp.net-core angular4


【解决方案1】:

问题是在第 13 行的boot-client.ts 文件中引起的:

module['hot'].dispose(() => { platform.destroy(); });

当删除 platform.destroy();它又开始工作了。所以这一行应该是这样的:

module['hot'].dispose(() => { });

【讨论】:

    猜你喜欢
    • 2016-06-09
    • 1970-01-01
    • 2016-06-09
    • 1970-01-01
    • 2016-11-24
    • 2018-09-23
    • 1970-01-01
    • 1970-01-01
    • 2020-03-06
    相关资源
    最近更新 更多