提交 bbe81b36 编写于 作者: Q qiang

fix: 修复页面切换后 textarea 组件 auto-height 失效的问题

上级 d7f5b5f4
<template>
<uni-resize-sensor @animationstart.once="update">
<div @scroll="update">
<div />
</div>
<div @scroll="update">
<div />
</div>
</uni-resize-sensor>
</template>
<script> <script>
const MAX = 100000
export default { export default {
name: 'ResizeSensor', name: 'ResizeSensor',
props: { props: {
...@@ -36,42 +48,23 @@ export default { ...@@ -36,42 +48,23 @@ export default {
this.reset() this.reset()
} }
}, },
activated () {
this.reset()
},
methods: { methods: {
reset: function () { reset: function () {
var expand = this.$el.firstChild const expand = this.$el.firstChild
var shrink = this.$el.lastChild expand.scrollLeft = MAX
expand.scrollLeft = 100000 expand.scrollTop = MAX
expand.scrollTop = 100000 const shrink = this.$el.lastChild
shrink.scrollLeft = 100000 shrink.scrollLeft = MAX
shrink.scrollTop = 100000 shrink.scrollTop = MAX
}, },
update: function () { update: function () {
this.size.width = this.$el.offsetWidth this.size.width = this.$el.offsetWidth
this.size.height = this.$el.offsetHeight this.size.height = this.$el.offsetHeight
this.reset() this.reset()
} }
},
render: function (create) {
return create('uni-resize-sensor', {
on: {
'~animationstart': this.update
}
}, [
create('div', {
on: {
scroll: this.update
}
}, [
create('div')
]),
create('div', {
on: {
scroll: this.update
}
}, [
create('div')
])
])
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册