This commit is contained in:
wong1988
2024-01-21 16:39:00 +08:00
parent cb774f321b
commit 8de4e58cb4
2 changed files with 50 additions and 5 deletions

View File

@@ -5,11 +5,16 @@
</view>
<view v-if="mode === 'base'" class="uni-dialog-content">
<slot>
<textarea class="uni-dialog-content-text" :value="content" :auto-height="false"
:maxlength="10000"></textarea>
<text class="uni-dialog-content-text">{{content}}</text>
</slot>
</view>
<view v-else class="uni-dialog-content">
<view v-if="mode === 'more'" class="uni-dialog-content">
<slot>
<textarea class="uni-dialog-content-text" :value="content" :auto-height="false"
:style="{'height':contentHeight}" :maxlength="10000"></textarea>
</slot>
</view>
<view v-if="mode === 'input'" class="uni-dialog-content">
<slot>
<input class="uni-dialog-input" v-model="val" :type="inputType" :placeholder="placeholderText"
:focus="focus">
@@ -117,7 +122,8 @@
return {
dialogType: 'warn',
focus: false,
val: ""
val: "",
contentHeight: '135px'
}
},
computed: {
@@ -146,6 +152,9 @@
},
value(val) {
this.val = val
},
content() {
this.getHeight()
}
},
created() {
@@ -185,6 +194,42 @@
},
close() {
this.popup.close()
},
getHeight() {
let height = '135px'
try {
if (this.mode != 'more') {
return
}
const count = (this.content.match(/\n/g) || []).length;
// 粗略高度
let temp = this.content.replaceAll("\n", "");
let col = temp.length / 18 + 1
let totalHeight = (col + count) * 15
// 568
let height2 = getApp().globalData.navInfo.window.height
let maxHeight = (height2 - 170) / 3
if (totalHeight > maxHeight) {
height = maxHeight + 'px'
} else {
height = totalHeight + 'px'
}
} catch (e) {
//TODO handle the exception
}
this.contentHeight = height
console.log("======", this.contentHeight);
}
}
}