논하다<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                  
    },
  }
}

사실successUploadhandleRemove는 사용할 필요가 없고 제출할 때 이미 서버에 업로드된 파일 관련 정보(예를 들어 서버 저장 경로, 유일한 표지 등)를 얻으면 된다.
관찰fileList 파일 업로드 전후에 아무런 변화가 없다는 것은 이 필드가 동적 추측이 아니라는 것을 의미한다. 서버가 데이터를 되돌려주는 목록을 저장하고 자세히 살펴보니 그렇다는 것을 알 수 있다. 사실el-upload 구성 요소에 속성이 있다uploadFiles는 위의 메시지 결과에 따라 동적 처리를 할 것이다. 업로드가 성공적으로 하나 증가했고 하나를 제거했다. 폼을 제출할 때 이 필드만 처리하면 된다.
더 나은 사용 절차는 다음과 같습니다.

    
        
                
        
    
    
          
    


export default {
  data () {
      return {
          fileList: [],
      }
  },
  methods: {
    submitForm (formName) {
        //                           
        this.$refs.uploada.uploadFiles
    },
  }
}

좋은 웹페이지 즐겨찾기