我遇到以下问题: 属性“内存”的类型不兼容。类型'{size:number;类型中缺少属性'0'。 价格:数量; } []',但类型为'[{size:number;价格:数量; }]'。
import {Component, OnInit} from '@angular/core';
import {products} from '../_mock-data/products';
import {Products} from '../_models/products.model';
products: Array<Products> = products;
我的模型:
export interface Products {
name: string;
price: string;
color: string;
memorySize: string;
display: string;
waterResistant: string;
camera: string;
frontCamera: string;
futures: string;
processor: string;
charging: string;
memory: [
{
size: number;
price: number;
}
];
image: [
{
color: string;
phoneColor: string;
path: [
{
img: string;
}
]
}
];
}
谢谢
尝试这样的事情: