Commit 71637956181c93ecb722870e00572937d293e7df
Committed by
小小鲁班
1 parent
f40cbae2
fix(long_page): long page height not work; !#zh: 长页面高度未生效
Showing
1 changed file
with
18 additions
and
12 deletions
front-end/h5/src/engine-entry.js
| @@ -60,17 +60,10 @@ const Engine = { | @@ -60,17 +60,10 @@ const Engine = { | ||
| 60 | ) | 60 | ) |
| 61 | }, | 61 | }, |
| 62 | renderPreview (pageElements) { | 62 | renderPreview (pageElements) { |
| 63 | - let pageWrapperStyle = { | ||
| 64 | - height: '100%', | ||
| 65 | - position: 'relative' | ||
| 66 | - } | 63 | + const pageWrapperStyle = this.isLongPage ? { |
| 64 | + height: window.__work.height + 'px' | ||
| 67 | 65 | ||
| 68 | - if (this.isLongPage) { | ||
| 69 | - pageWrapperStyle = { | ||
| 70 | - ...pageWrapperStyle, | ||
| 71 | - 'overflow-y': 'scroll' | ||
| 72 | - } | ||
| 73 | - } | 66 | + } : {} |
| 74 | 67 | ||
| 75 | const elements = pageElements.map(element => new Element(element)) | 68 | const elements = pageElements.map(element => new Element(element)) |
| 76 | return ( | 69 | return ( |
| @@ -84,13 +77,26 @@ const Engine = { | @@ -84,13 +77,26 @@ const Engine = { | ||
| 84 | } | 77 | } |
| 85 | </div> | 78 | </div> |
| 86 | ) | 79 | ) |
| 80 | + }, | ||
| 81 | + getContainerStyle(work) { | ||
| 82 | + const containerStyle = { | ||
| 83 | + position: 'relative', | ||
| 84 | + height: '100%', | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + if (this.isLongPage) { | ||
| 88 | + containerStyle['overflow-y'] = 'scroll' | ||
| 89 | + } | ||
| 90 | + return containerStyle | ||
| 87 | } | 91 | } |
| 88 | }, | 92 | }, |
| 89 | render (h) { | 93 | render (h) { |
| 90 | const work = window.__work | 94 | const work = window.__work |
| 91 | - return <div id="work-container" data-work-id={work.id}> | 95 | + const containerStyle = this.getContainerStyle(work) |
| 96 | + | ||
| 97 | + return <div id="work-container" data-work-id={work.id} style={containerStyle}> | ||
| 92 | { | 98 | { |
| 93 | - this.isLongPage ? this.renderLongPage() : this.renderSwiperPage() | 99 | + this.isLongPage ? this.renderLongPage() : this.renderSwiperPage() |
| 94 | } | 100 | } |
| 95 | </div> | 101 | </div> |
| 96 | } | 102 | } |