1. a 标签
// event 是浏览器生成的对象
<a target="_blank" onclick="openDetail(event,\''+ data[i].id +'\')" style="color: #3D87EB;">详情</a>
function openDetail(event,val){
event.target.href = layui.sight.compileUrl("/file/downloadFile?gl_id=" + val)
}
2. window.open
window.open(layui.sight.compileUrl("/file/downloadFile?gl_id=" + val))
3. PDF.js
官网: PDF.JS
从官网下载后 包放在static目录下 以下方法适用于返回的是文件流
function openDetail(val){
window.open('${rc.contextPath}/static/pdfjs-2.10.377-dist/web/viewer.html?file=' +encodeURIComponent(layui.sight.compileUrl("/file/downloadFile?gl_id=" + val)));
// encodeURIComponent 函数可把字符串作为URI组件进行编码 因为此处有多个URL 里面有多个 ?
}