Invalid prop: type check failed for prop "previewSrcList". Expected Array, got Number with value 1.
时间: 2023-11-23 12:56:50 浏览: 161
2020-web前端-vue项目出错-[Vue warn]: Invalid prop: custom validator check failed for prop “index”.
5星 · 资源好评率100%
这个错误提示是因为代码中传递给"previewSrcList"属性的值类型不正确,期望是一个数组,但实际传递了一个数字1。需要检查代码中传递给该属性的值是否正确。
以下是一个演示如何正确传递数组给"previewSrcList"属性的例子:
```html
<template>
<div>
<el-image-preview :visible.sync="dialogVisible" :src-list="previewSrcList"></el-image-preview>
<el-button @click="showDialog">显示图片</el-button>
</div>
</template>
<script>
export default {
data() {
return {
dialogVisible: false,
previewSrcList: [
'https://xxx.com/image1.jpg',
'https://xxx.com/image2.jpg',
'https://xxx.com/image3.jpg'
]
}
},
methods: {
showDialog() {
this.dialogVisible = true
}
}
}
</script>
```
阅读全文