优化sandbox的高度自适应
parent
c86a1d9dc6
commit
fb8c2b00d9
|
@ -192,7 +192,7 @@ class Sandbox extends Component {
|
|||
contentLoaded(ev) {
|
||||
let elem = ev.target
|
||||
let body = elem.contentDocument.body
|
||||
elem.style.height = body.clientHeight + 'px'
|
||||
elem.style.height = body.scrollHeight + 10 + 'px'
|
||||
}
|
||||
|
||||
renderTemplate() {
|
||||
|
@ -207,9 +207,17 @@ class Sandbox extends Component {
|
|||
|
||||
mounted() {
|
||||
//
|
||||
this.#cache.preview.panel = this.$refs.preview
|
||||
let target = this.$refs.preview
|
||||
this.#cache.preview.panel = target
|
||||
this.renderTemplate()
|
||||
this.$refs.preview.style.display = 'block'
|
||||
target.style.display = 'block'
|
||||
|
||||
this.__observer = new ResizeObserver(_ => this.contentLoaded({ target }))
|
||||
this.__observer.observe(target.contentDocument.body)
|
||||
}
|
||||
|
||||
unmounted() {
|
||||
this.__observer?.disconnect()
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
Loading…
Reference in New Issue