file-viewer-demo/src/App.vue

80 lines
1.6 KiB
Vue
Raw Normal View History

2024-01-30 07:57:29 +00:00
2024-01-29 06:17:29 +00:00
<template>
2024-01-30 07:57:29 +00:00
<header>
<div class="tool-bar">
<div>
<h3>选择预览模式</h3>
<input type="radio" name="mode" value="inner" v-model="mode" />内置访问
<input type="radio" name="mode" value="embedded" v-model="mode" />iframe访问
</div>
<div>
<h3>选择文档</h3>
<select v-model="url">
<optgroup label="excel">
<option :value="excel">常规excel</option>
</optgroup>
<optgroup label="pdf">
<option :value="pdf1">复杂pdf</option>
<option :value="pdf2">简单pdf</option>
</optgroup>
</select>
</div>
</div>
<div class="wrapper">
<InnerViewer v-if="mode === 'inner'" :url="url" />
<IframeViewer v-else-if="mode === 'embedded'" :url="url" />
</div>
</header>
2024-01-29 06:17:29 +00:00
</template>
<script>
2024-01-30 07:57:29 +00:00
import InnerViewer from './components/InnerViewer'
import IframeViewer from "./components/IframeViewer";
// 测试文件,这些文件实际情况可能是其他服务器链接
const excel = 'excel.xlsx';
const pdf1 = '666.pdf';
const pdf2 = '888.pdf';
2024-01-29 06:17:29 +00:00
export default {
name: 'App',
2024-01-30 07:57:29 +00:00
data() {
return {
url: excel,
mode: 'inner',
excel,
pdf1,
pdf2,
}
},
2024-01-29 06:17:29 +00:00
components: {
2024-01-30 07:57:29 +00:00
InnerViewer,
IframeViewer
2024-01-29 06:17:29 +00:00
}
}
</script>
2024-01-30 07:57:29 +00:00
<style scoped>
header {
line-height: 1.5;
}
.tool-bar {
background-color: hsla(160, 100%, 37%, 0.2);
width: 230px;
height: 100vh;
padding-left: 8px;
}
@media (min-width: 1024px) {
header {
display: flex;
position: relative;
}
header .wrapper {
flex: 1;
}
2024-01-29 06:17:29 +00:00
}
</style>