大咖總結的前端知識點:框架中報錯集錦(含解決方法!)

大咖總結的前端知識點:框架中報錯集錦(含解決方法!)

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:

  1. If 'demo01' is an Angular component, then verify that it is part of this module.

  2. 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的調試

大咖總結的前端知識點:框架中報錯集錦(含解決方法!)

寫在最後

大咖的話:

“最近有很多想學習編程的朋友問我有沒有什麼好的編程資料!因為最近今年我都在認真蒐集有價值的編程資料,技術資料,只為幫助那些想學習編程而不知道從哪開始的朋友。

下圖就是(部分資料截圖):

大咖總結的前端知識點:框架中報錯集錦(含解決方法!)

以上價值3萬元的資料,絕對比群裡那些漫天飛的資料強多了。今天決定免費分享,用來感謝大家的支持。”

免費獲取方式:

關注公眾號:“雞蛋君說前端”,即可免費領取3萬元全棧開發視頻資料!


分享到:


相關文章: