angular报错信息之 The selector "app" did not match any elements
文章栏目162716270
发布时间:2019-10-14 16:41:30

概述

angular报错信息之The selector "app" did not match any elements
//选择器“app”与任何元素都不匹配

Unhandled Promise rejection: The selector "app" did not match any elements ; Zone: `<root>` ; Task: Promise.then ; Value: Error: The selector "app" did not match any elements
//未处理的承诺拒绝:选择器“app”不匹配任何元素;区域:;任务:promise.then;值:错误:选择器“app”不匹配任何元素

当前错误原因是我们绑定在页面上的选择器不正确,

AppComponentHost.ngfactory.js? [sm]:1 ERROR Error: The selector "app" did not match any elements
    at DefaultDomRenderer2.selectRootElement (vendor.js:115586)
    at DebugRenderer2.selectRootElement (vendor.js:67167)
    at createElement (vendor.js:62443)
    at createViewNodes (vendor.js:65581)
    at createRootView (vendor.js:65497)
    at callWithDebugContext (vendor.js:66985)
    at Object.debugCreateRootView [as createRootView] (vendor.js:66232)
    at ComponentFactory.create (vendor.js:63235)
    at ComponentFactoryBoundToModule.create (vendor.js:56573)
    at ApplicationRef.bootstrap (vendor.js:58003)

angular报错信息之 The selector "app" did not match any elements

解决方法

一般文件设置selector在app.component.ts文件下修改当前值与src/index.html主页面一致即可