借助微软在线工具,实现预览文件功能

使用微软的office online实现文件预览

把文件地址拼接放到在线地址后面,具体实现如下:

checkFile(path) {
	// 查看附件
	if (path) {
		const typeArr = ['doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx', 'pdf'];
		let arr = path.split('.');
		let fileType = arr[arr.length-1];
		let url = '';
		if (typeArr.indexOf(fileType) !== -1) {
			// 使用微软的office online
			url = 'http://view.xdocin.com/xdoc?_xdoc=' + path;
		} else {
			url = path;
		}
		// window.location.href = path;
		window.open(url);
	}
},

猜你喜欢

转载自blog.csdn.net/qq_42563079/article/details/129562083
今日推荐