논하다<br>올바른 사용 방법
2382 단어 element-ui
의 정확한 사용 방법 표에 업로드 컨트롤이 있는데 남겨진 코드를 보면 이렇게 사용됩니다.
export default {
data () {
return {
fileList: [],
ruleForm: {
fileList: []
},
}
},
methods: {
handleRemove (file, fileList) {
//
let tmp = this.ruleForm.fileList
let url = file.response.result[0].url
if (tmp.includes(url)) {
tmp.splice(tmp.findIndex(item => {
return item === url
}), 1)
}
},
successUpload (response, file, fileList, $event) {
//
this.ruleForm.fileList.push(file.response.result[0].url)
},
submitForm (formName) {
let fileList = this.ruleForm.fileList
// fileList
},
}
}
사실
successUpload
과handleRemove
는 사용할 필요가 없고 제출할 때 이미 서버에 업로드된 파일 관련 정보(예를 들어 서버 저장 경로, 유일한 표지 등)를 얻으면 된다.관찰
fileList
파일 업로드 전후에 아무런 변화가 없다는 것은 이 필드가 동적 추측이 아니라는 것을 의미한다. 서버가 데이터를 되돌려주는 목록을 저장하고 자세히 살펴보니 그렇다는 것을 알 수 있다. 사실el-upload
구성 요소에 속성이 있다uploadFiles
는 위의 메시지 결과에 따라 동적 처리를 할 것이다. 업로드가 성공적으로 하나 증가했고 하나를 제거했다. 폼을 제출할 때 이 필드만 처리하면 된다.더 나은 사용 절차는 다음과 같습니다.
export default {
data () {
return {
fileList: [],
}
},
methods: {
submitForm (formName) {
//
this.$refs.uploada.uploadFiles
},
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
ElementUI+vuex 기반 양식 유효성 검사 공유(5.6 빠른 추가 설명)프로젝트는 vue+elementUI를 기반으로 한 백그라운드 관리 시스템입니다.프로젝트에서 표에 대한 검증이 많이 언급되었는데 초기에 프로젝트의 진도를 감히 하기 위해 이 백엔드 시스템의 표 검증에 대해 통일을 하지...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.