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)
    }
posted @ 2023-06-16 09:56  彳小闲鱼  阅读(641)  评论(0编辑  收藏  举报