요청 데이터 스트림 및 다운로드를 가져

그리고 인수 스트림 데이터 다운로드의 프런트 엔드입니다.

설정 응답 타입의 1 후단

. 1 response.setContentType ( "파일 응용 프로그램 / octet-stream을"); // 설정 응답 유형

(2)에 의해 취득 원위 스트림을 페치

()에 의해 response.blob bolb를 취득

. (1) app.fetch ( '/의 xD / 편집기 / 총 / 작업량' 함수 (대응) {
 2              response.blob (). 그 후에 ((BLOB) => {
 . 3                  saveBlobAs (BLOB 'result.xls' )
 . 4              })
 . 5          }, 함수 (결과) {
 6.              console.info ( 「데이터 취득 실패」+ result.message)
 . 7          })
 . 8  
. 9  // bolb 보존 방법 
10  함수 saveBlobAs (BLOB, 파일명) {
 . 11          IF (window.navigator .msSaveOrOpenBlob) {
 12은             navigator.msSaveBlob (BLOB, 파일명)
 13          } 다른 {
 14              CONST 앵커 = document.createElement ( "A" )
 15              CONST 본체 document.querySelector = ( '신체' )
 16              anchor.href = window.URL.createObjectURL (방울)
 17              anchor.download = 파일명
 18  
19              anchor.style.display = '없음'
 20              body.appendChild (앵커)
 21  
22              anchor.click ()
 23              body.removeChild (앵커)
 24  
25             window.URL.revokeObjectURL (anchor.href)
 26          }
 27      }

 

추천

출처www.cnblogs.com/jyughynj/p/12625983.html