<el-button type = "text" @click="addImage"><el-icon><Plus /></el-icon>添加图片</el-button>
定义了:
interface Model {
name: string;
img: object[]
}
const model = ref<Model>({
name: '',
img: [{}],
});
const addImage = () => {
model.value.img.push({'img':'baidu.com'});
};
点按钮提示“TypeError: Cannot read properties of undefined (reading 'push') at addImage”