반응형
Vue - 인쇄 어레이
나는 이 모델을 가지고 있다.files
내가 가지고 있는 재산은response
안에 배열이 있다는 것errorMessages
그리고 내 Vue 구성 요소 내부에서 어레이 형식이 아닌 오류를 하나씩 보여 주고 싶다.
어떻게 할 방법이 없을까?
{
"files": [
{
"fileObject": true,
"size": 9387,
"name": "file_4444.pdf",
"type": "application/pdf",
"active": false,
"error": true,
"success": true,
"postAction": "http://localhost:8000/api/v1/car/upload",
"timeout": 0,
"file": {},
"el": {
"__vue__": null
},
"response": {
"uploadDone": 0,
"uploadFail": 1,
"errorMessages": [
"User not found",
"Car not found",
]
},
"progress": "100.00",
"speed": 9591,
"data": {},
"headers": {},
"id": "096vnj6rov9t",
"xhr": {}
}
]
}
<template>
<div class="example-drag">
<div class="upload">
<ul v-if="files.length">
<li v-for="(file, index) in files" :key="file.id">
<span>{{file.name}}</span> -
<span v-if="file.error"> {{ file.response.errorMessages }} <md-icon>thumb_down</md-icon> </span>
<span v-else-if="file.success">success <md-icon>thumb_up</md-icon> </span>
<span v-else-if="file.active">active <md-icon>thumb_up</md-icon> </span>
<span v-else> ... </span>
</li>
</ul>
...
</template>
errorMessages 어레이에 반복해야 함
<ul v-if="files.length">
<li v-for="(file, index) in files" :key="file.id">
<span>{{file.name}}</span> -
<span v-if="file.error">
<ol>
<li v-for="err in file.response.errorMessages> {{ err }} </li>
</ol>
</span>
</li>
</ul>
또는 다음 항목을 사용하십시오..join
배열 방법(['hola', 'mundo'].join(", ") => 'hola, mundo'
)
<span v-if="file.error">{{ file.response.errorMessages.join(", ") }}</span>
{
"files": [
{
"fileObject": true,
"size": 9387,
"name": "file_4444.pdf",
"type": "application/pdf",
"active": false,
"error": true,
"success": true,
"postAction": "http://localhost:8000/api/v1/car/upload",
"timeout": 0,
"file": {},
"el": {
"__vue__": null
},
"response": {
"uploadDone": 0,
"uploadFail": 1,
"errorMessages": [
"User not found",
"Car not found",
]
},
"progress": "100.00",
"speed": 9591,
"data": {},
"headers": {},
"id": "096vnj6rov9t",
"xhr": {}
}
]
}
참조URL: https://stackoverflow.com/questions/49152074/vue-print-array
반응형
'Programing' 카테고리의 다른 글
형제 패키지 가져오기 (0) | 2022.03.17 |
---|---|
Python은 단락을 지원하는가? (0) | 2022.03.17 |
Vue v-On:클릭이 구성 요소에서 작동하지 않음 (0) | 2022.03.17 |
jwt - Vue.js에 토큰을 저장할 위치 (0) | 2022.03.17 |
Vue.js에서 이스케이프되지 않은 HTML 표시 (0) | 2022.03.17 |