编译报错,请问怎样解决?
来源:8-5 本章实战上

斜杠男人
2018-01-20
webpack: Compiled successfully.
ERROR in src/app/stock/stock-form/stock-form.component.ts(36,9): error TS2322: Type 'Stock[]' is not assignable to type 'Stock'.
src/app/stock/stock-form/stock-form.component.ts(36,9): error TS2322: Type 'Stock[]' is not assignable to type 'Stock'.
Property 'id' is missing in type 'Stock[]'.
src/app/stock/stock-form/stock-form.component.ts(38,22): error TS2339: Property 'name' does not exist
on type 'Stock[]'.
src/app/stock/stock-form/stock-form.component.ts(39,23): error TS2339: Property 'price' does not exist on type 'Stock[]'.
src/app/stock/stock-form/stock-form.component.ts(40,22): error TS2339: Property 'desc' does not exist
on type 'Stock[]'.
src/app/stock/stock-form/stock-form.component.ts(42,18): error TS2339: Property 'categories' does not
exist on type 'Stock[]'.
src/app/stock/stock-form/stock-form.component.ts(43,18): error TS2339: Property 'categories' does not
exist on type 'Stock[]'.
src/app/stock/stock-form/stock-form.component.ts(44,18): error TS2339: Property 'categories' does not
exist on type 'Stock[]'.
1回答
-
JoJo
2018-01-22
stockService.getStock返回的是Stock[]么?错误是说你不能把一个Stock[]类型的值赋给一个Stock类型的变量
012018-07-05
相似问题