| 123456789101112131415161718 |
- import Config from '@/config/index'
- const { Host80 } = Config
- import getWebBase from '@/utils/webBase'
- const webBase = getWebBase()
- // utils/pdf.js 或直接在组件 methods 中定义
- export function openLocalPdf(fileName, title) {
- // #ifdef H5
- // H5 端直接打开相对路径,会被浏览器渲染或下载(取决于浏览器配置)
- window.open(`${Host80}${webBase}static/${fileName}`);
- // #endif
- // #ifdef APP-PLUS
- // App 端:将静态资源路径转为系统绝对路径,再用 uni.openDocument 调用系统阅读器打开
- uni.navigateTo({
- url: `/pages/common/webview?url=${encodeURIComponent(`${Host80}${webBase}static/${fileName}`)}&title=${title}`
- });
- // #endif
- }
|