pinch-zoom-js 在vue 中的安装、 使用
npm i pinch-zoom-js --saveimport 导入import PinchZoom from 'pinch-zoom-js'动态设置高度<div id="father" :style="{ height: height }"><div id="vhtml" v-html="content" /></div...
·
npm i pinch-zoom-js --save
import 导入
import PinchZoom from 'pinch-zoom-js'
动态设置高度
<div id="father" :style="{ height: height }">
<div id="vhtml" v-html="content" />
</div>
js方法
data() {
return {
height: '500px'
}
},
mounted() {
this.$nextTick(() => {
this.reSetSize()
setTimeout(() => {
const el = document.getElementById('vhtml')
new PinchZoom(el, {})
}, 1000)
})
},
methods: {
// 获取宽高
reSetSize() {
this.$nextTick(() => {
const height = window.innerHeight || document.documentElement.clientHeight
this.height = height - 46 + 'px'
console.log(this.height)
})
}
}
标记文本
遇到的坑:
1、导入
2、获取元素
3、动态设置高度的问题
更多推荐
已为社区贡献6条内容
所有评论(0)