web前端知识点太多_前端知识点总结——框架中报错集锦(含解决方法)
前端知識點總結——框架中報錯集錦(含解決方法)
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. (“
Hello {{name}}
[ERROR ->]
解決方案:
是以模塊為基本單位,所創建的組件到要指定屬于哪個模塊
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 ‘#’
無法修改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:
原因:多數都是因為類名稱寫錯
解決方案:反復檢查引入的類名字有沒有寫錯
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
總結
以上是生活随笔為你收集整理的web前端知识点太多_前端知识点总结——框架中报错集锦(含解决方法)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 小班社会优质课教案《咕噜噜》反思
- 下一篇: 2017年html5行业报告,云适配发布