vue在线预览pdf、word、xls、ppt等office文件

perview(row){
      const typeArr = ['doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx']
      let arr=row.url.split('.')
      let fileType=arr[arr.length-1]
      let url = ''
      if (typeArr.indexOf(fileType) !== -1) {
        // 使用微软的office online
        url='http://view.xdocin.com/xdoc?_xdoc='+row.url
      } else {
        url = row.url
      }
      // window.open()居中打开
      const width = 1000; const height = 800
      const top = (window.screen.availHeight - height) / 2
      const left = (window.screen.availWidth - width) / 2
      window.open(url, '', 'width=' + width + ',height=' + height + ',top=' + top + ',left=' + left)
    }

你可能感兴趣的:(vue在线预览pdf、word、xls、ppt等office文件)