50 lines
1.4 KiB
Vue
50 lines
1.4 KiB
Vue
<template>
|
|
<!-- <div class="iframe-container">-->
|
|
<iframe :src="previewUrl" class="responsive-iframe" frameborder="0"></iframe>
|
|
<!-- </div>-->
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data () {
|
|
return {
|
|
previewUrl: ''
|
|
}
|
|
},
|
|
mounted () {
|
|
console.log('file preview mounted')
|
|
this.previewUrl = this.$route.query.previewUrl
|
|
console.log('this.previewUrl1', this.previewUrl)
|
|
console.log('process.env.BASE_URL', process.env.BASE_URL)
|
|
if (this.previewUrl.startsWith('/')) { // pdf的 url特殊处理下
|
|
const index = this.previewUrl.indexOf('file=')
|
|
const firstPart = this.previewUrl.substring(0, index)
|
|
const secondPart = this.previewUrl.substring(index + 5)
|
|
this.previewUrl = 'http://' + window.location.host + firstPart + encodeURIComponent(secondPart)
|
|
// this.previewUrl = 'http://' + window.location.host + encodeURIComponent(this.previewUrl)
|
|
// window.open(this.previewUrl)
|
|
}
|
|
console.log('this.previewUrl2', this.previewUrl)
|
|
|
|
// console.log('this.$route', this.$route)
|
|
// console.log('window.location.host', window.location.host)
|
|
}
|
|
}
|
|
</script>
|
|
<style>
|
|
.iframe-container {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100vh;
|
|
-webkit-overflow-scrolling: touch; /* 当手指从触摸屏上移开,会保持一段时间的滚动 */
|
|
overflow-y: scroll;
|
|
}
|
|
|
|
.responsive-iframe {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
</style>
|