提交 a39d8efc 编写于 作者: Q qiang

fix: 解决H5端textarea组件未设置line-height时linechange事件得到到lineCount错误的问题 fixed #1123

上级 c576892e
...@@ -23,13 +23,16 @@ ...@@ -23,13 +23,16 @@
:class="placeholderClass" :class="placeholderClass"
class="uni-textarea-placeholder" class="uni-textarea-placeholder"
>{{ placeholder }}</div> >{{ placeholder }}</div>
<div
ref="line"
class="uni-textarea-line">&nbsp;</div>
<div class="uni-textarea-compute"> <div class="uni-textarea-compute">
<div <div
v-for="(item,index) in valueCompute" v-for="(item,index) in valueCompute"
:key="index">{{ item.trim() ? item : '.' }}</div> :key="index">{{ item.trim() ? item : '.' }}</div>
<v-uni-resize-sensor <v-uni-resize-sensor
ref="sensor" ref="sensor"
@resize="_resize"/> @resize="_resize" />
</div> </div>
<textarea <textarea
ref="textarea" ref="textarea"
...@@ -188,7 +191,10 @@ export default { ...@@ -188,7 +191,10 @@ export default {
this._checkSelection() this._checkSelection()
}, },
height (height) { height (height) {
const lineHeight = getComputedStyle(this.$el).lineHeight.replace('px', '') let lineHeight = parseFloat(getComputedStyle(this.$el).lineHeight)
if (isNaN(lineHeight)) {
lineHeight = this.$refs.line.offsetHeight
}
var lineCount = Math.round(height / lineHeight) var lineCount = Math.round(height / lineHeight)
this.$trigger('linechange', {}, { this.$trigger('linechange', {}, {
height, height,
...@@ -305,6 +311,7 @@ uni-textarea[auto-height] .uni-textarea-textarea { ...@@ -305,6 +311,7 @@ uni-textarea[auto-height] .uni-textarea-textarea {
} }
.uni-textarea-wrapper, .uni-textarea-wrapper,
.uni-textarea-placeholder, .uni-textarea-placeholder,
.uni-textarea-line,
.uni-textarea-compute, .uni-textarea-compute,
.uni-textarea-textarea { .uni-textarea-textarea {
outline: none; outline: none;
...@@ -320,6 +327,7 @@ uni-textarea[auto-height] .uni-textarea-textarea { ...@@ -320,6 +327,7 @@ uni-textarea[auto-height] .uni-textarea-textarea {
height: 100%; height: 100%;
} }
.uni-textarea-placeholder, .uni-textarea-placeholder,
.uni-textarea-line,
.uni-textarea-compute, .uni-textarea-compute,
.uni-textarea-textarea { .uni-textarea-textarea {
position: absolute; position: absolute;
...@@ -334,10 +342,14 @@ uni-textarea[auto-height] .uni-textarea-textarea { ...@@ -334,10 +342,14 @@ uni-textarea[auto-height] .uni-textarea-textarea {
color: grey; color: grey;
overflow: hidden; overflow: hidden;
} }
.uni-textarea-line,
.uni-textarea-compute { .uni-textarea-compute {
visibility: hidden; visibility: hidden;
height: auto; height: auto;
} }
.uni-textarea-line {
width: 1em;
}
.uni-textarea-textarea { .uni-textarea-textarea {
resize: none; resize: none;
background: none; background: none;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册