반응형
Vue.js - 요소 UI - POST 요청을 트리거하지 않고 업로드 구성 요소 사용
Element UI의 업로드 구성 요소를 사용하고 있습니다.안타깝게도 파일이 업로드되는 즉시 POST 요청이 트리거됩니다.제가 목표로 하는 것은 파일을 빈 배열에 푸시하는 것입니다.이 배열은 버튼을 누르면 나중에 게시됩니다.
HTML
// Element UI documentation says http-request overrides xhr behavior
// so I can use my own file request. In this case, I wanted to use a method
// though I'm not quite sure about this part?
<el-upload
action="",
:http-request="addAttachment",
:on-remove="deleteAttachment",
:file-list="attachments">
<el-button size="mini" type="primary">Add file</el-button>
</el-upload>
// button that uploads the files here
JS
data() {
attachments: []
},
methods: {
addAttachment ( file, fileList ) {
this.attachments.push( file );
},
deleteAttachment () {
// removes from array
}
}
듣자하니, 당신은 또 다른 세팅도 해야 합니다.auto-upload
되려 하다false
그렇지 않으면 디폴트로true
파일 업로드가 자동으로 시도됩니다.http-request
소품
고객님의 경우:
<el-upload
action="",
:http-request="addAttachment",
:auto-upload="false"
:on-remove="deleteAttachment",
:file-list="attachments"
>
<el-button size="mini" type="primary">Add file</el-button>
</el-upload>
언급URL : https://stackoverflow.com/questions/46594146/vue-js-element-ui-use-upload-component-without-post-request-triggering
반응형
'sourcecode' 카테고리의 다른 글
VueJS 애플리케이션을 통해 Google Analytics 4의 사용자 지정 차원을 전달하려면 어떻게 해야 합니까? (0) | 2022.08.16 |
---|---|
Java에서 문자열을 UTF8 바이트 배열로 변환하는 방법 (0) | 2022.08.15 |
Java 열거형과 공개 정적 최종 필드가 있는 클래스의 장점은 무엇입니까? (0) | 2022.08.15 |
Vuex 작업에 vue-resource를 사용해야 합니까? (0) | 2022.08.15 |
Vue.js 슬롯 속성 사용 방법 (0) | 2022.08.15 |