前端知识点总结——框架中报错集锦(含解决方法)
1.vue
1、指定template直接返回多个标签
Component template should contain exactly one root element.
解决方案:指定一个容器,将需要返回的多个标签放在这个容器中 div/form/a...
2、读取了一个变量的属性但是这个变量是undefined
多数情况都是因为作用域问题
Cannot read property '*' of undefined
3、死循环
2.ng
1、模板解析失败
Template parse errors:
'demo01' is not a known element:
- If 'demo01' is an Angular component,then verify that it is part of this module.
- If 'demo01' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("<h1>Hello {{name}}</h1>
[ERROR ->]<demo01></demo01>
解决方案:
是以模块为基本单位,所创建的组件到要指定属于哪个模块
2、ZoneAwareError
点开,查看message
3、Can't have multiple template bindings on one element.
不能在同一个元素上边 调用多个结构性指令
ng-container
4、No provider for UserService!
DI error ! Dependency Injection 依赖注入
有可能是因为没有给服务指定提供商
解决方案:
①到模块或者组件中 指定providers属性!! ②在引入服务去指定Providers,引入服务的路径写错
5、No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access
header('Access-Control-Allow-Origin:*');
6、Unexpected value 'undefined' imported by the module 'AppModule
在AppModule引入其他模块,模块不存在!
7、没有给某个组件 去指定 模板内容
(SystemJS) No template specified for component LoginComponent
8、一个selector的名称用了很多次
More than one component matched on this element.
Make sure that only one component's selector can match a given element.
解决方案:保证每一个组件的selector名字都是唯一的
3.React
1、Uncaught SyntaxError: embedded: Adjacent JSX elements must be wrapped in an enclosing tag (4:16)
2、Cannot assign to read only property 'btnName' of object '#<Object>'
无法修改props对应的值
ReactNative*
1、Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in.
导出的类如果加上了default,引入是无需写{},写了花括号就会报错
引入的组件类的名称是不是写错了
2、The development server returned response error code: 500
500错误,内部错误,有可能是因为当前启动的开发服务器失败。
解决方案:
找到vscode终端,在终端的最下边,往上找,红色的error
3、Can't find variable: <unknown>
原因:多数都是因为类名称写错
解决方案:反复检查引入的类名字有没有写错
4、Expected a component class,got [object Object].
不允许出现html标签
5、undefined is not a function (evaluating 'arr[typeof Symbol === "function" ? Symbol.iterator : "@@iterator"]()')
因为手工拷贝过来的nodeModules的问题。
解决方案:只需要开启远程js的调试
按下菜单键或者摇一摇,在弹出菜单中,选中debug js remotely原文链接:https://www.f2er.com/angularjs/144785.html