77 lines
1.6 KiB
Vue
77 lines
1.6 KiB
Vue
<template>
|
|
<view class="content">
|
|
<view class="frame-wrap" :style="{ height: wrapHeight + 'px' }">
|
|
<iframe class="frame" :src="url" frameborder="0" :style="frameStyle"></iframe>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
url: '',
|
|
title: '',
|
|
frameWidth: 1200,
|
|
screenW: 375,
|
|
wrapHeight: 600,
|
|
vpSaved: ''
|
|
}
|
|
},
|
|
computed: {
|
|
scale() {
|
|
return this.screenW / this.frameWidth
|
|
},
|
|
frameStyle() {
|
|
const h = Math.ceil(this.wrapHeight / this.scale)
|
|
return 'width:' + this.frameWidth + 'px;height:' + h + 'px;transform:scale(' + this.scale + ');transform-origin:0 0;'
|
|
}
|
|
},
|
|
onLoad(options) {
|
|
this.url = decodeURIComponent(options.url || '')
|
|
this.title = decodeURIComponent(options.title || '法规原文')
|
|
const meta = document.querySelector('meta[name="viewport"]')
|
|
if (meta) {
|
|
this.vpSaved = meta.getAttribute('content') || ''
|
|
meta.setAttribute('content', 'width=device-width,initial-scale=1.0,maximum-scale=3.0,user-scalable=yes')
|
|
}
|
|
},
|
|
onReady() {
|
|
const sys = uni.getSystemInfoSync()
|
|
this.screenW = sys.windowWidth
|
|
this.wrapHeight = sys.windowHeight
|
|
},
|
|
onUnload() {
|
|
const meta = document.querySelector('meta[name="viewport"]')
|
|
if (meta && this.vpSaved) {
|
|
meta.setAttribute('content', this.vpSaved)
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
page {
|
|
background-color: #fff;
|
|
}
|
|
|
|
.content {
|
|
position: relative;
|
|
width: 100%;
|
|
max-width: 100vw;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.frame-wrap {
|
|
position: relative;
|
|
width: 100%;
|
|
overflow: hidden;
|
|
background: #fff;
|
|
}
|
|
|
|
.frame {
|
|
display: block;
|
|
border: none;
|
|
}
|
|
</style>
|