为了账号安全,请及时绑定邮箱和手机立即绑定

报错 error TS2322: Type 'Stock' is not assignable to type 'string'. 怎么回事

报错 error TS2322: Type 'Stock' is not assignable to type 'string'. 怎么回事

油条C 2018-11-26 23:01:17
private stocks: Array<string>;   constructor() {   }   ngOnInit() {     this.stocks = [       // new Stock(1,"第一只股票",1.99,3.5,"这是第一只股票,是我在学习慕课网Angular入门实战时创建的",["IT","互联网"]),       new Stock(1, "第一只股票", 1.99, 5.0, "这是第一只股票,是我在学习慕课网Angular入门实战时创建的", ["IT","互联网"])     //   new Stock(2, '第二只股票', 2.99, 4.5, '这是第二只股票,是我在学习慕课网Angular入门实战时创建的', ['金融']),     //   new Stock(3, '第三只股票', 3.99, 3.5, '这是第三只股票,是我在学习慕课网Angular入门实战时创建的', ['IT']),     //   new Stock(4, '第四只股票', 4.99, 2.5, '这是第四只股票,是我在学习慕课网Angular入门实战时创建的', ['互联网']),     //   new Stock(5, '第五只股票', 5.99, 1.5, '这是第五只股票,是我在学习慕课网Angular入门实战时创建的', ['金融']),     //   new Stock(6, '第六只股票', 6.99, 5.0, '这是第六只股票,是我在学习慕课网Angular入门实战时创建的', ['IT', '金融']),     //   new Stock(7, '第七只股票', 7.99, 3.5, '这是第七只股票,是我在学习慕课网Angular入门实战时创建的', ['金融', '互联网']),     //   new Stock(8, '第八只股票', 8.99, 2.5, '这是第八只股票,是我在学习慕课网Angular入门实战时创建的', ['黄金', '互联网'])     ];   } } export class Stock {   constructor(     public id: number,     public name: string,     public price: number,     public rating: number,     public desc: string,     public categories: Array<string>) {   } }请问 报错 error TS2322: Type 'Stock' is not assignable to type 'string'. 怎么回事
查看完整描述
  • 3 回答
  • 0 关注
  • 5729 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信