Realize the function of previewing files with the help of Microsoft online tools

Using Microsoft Office Online to Realize File Preview

Put the file address splicing behind the online address, the specific implementation is as follows:

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);
	}
},

Guess you like

Origin blog.csdn.net/qq_42563079/article/details/129562083