fix: 功能完善修复。
This commit is contained in:
@@ -2,10 +2,6 @@
|
||||
* uView u-input 组件补丁
|
||||
* 直接用预存的补丁文件覆盖原始文件
|
||||
* 使下拉选择框(readonly/disabled)超长文字可自动换行完整显示
|
||||
*
|
||||
* 修改内容详见 scripts/u-input.vue(已修改好的完整文件)
|
||||
*
|
||||
* 通过 package.json 的 postinstall 自动执行
|
||||
*/
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view
|
||||
class="u-input"
|
||||
:class="[inputClass, isSelectLike ? 'u-input--selectlike' : '']"
|
||||
:class="[inputClass, isSelectLike ? 'u-input--selectlike' : '', isSearchInput ? 'u-input--search-input' : '']"
|
||||
:style="[wrapperStyle]"
|
||||
>
|
||||
<view class="u-input__content">
|
||||
@@ -205,6 +205,14 @@ export default {
|
||||
isSelectLike() {
|
||||
return this.type === 'select' || this.disabled || this.readonly
|
||||
},
|
||||
isSearchInput() {
|
||||
const customStyle = this.customStyle
|
||||
if (typeof customStyle === 'string') {
|
||||
return customStyle.includes('height: 66rpx') && customStyle.includes('border-radius: 24rpx')
|
||||
}
|
||||
const style = uni.$u.addStyle(customStyle)
|
||||
return style.height === '66rpx' && (style.borderRadius === '24rpx' || style['border-radius'] === '24rpx')
|
||||
},
|
||||
// 是否显示清除控件
|
||||
isShowClear() {
|
||||
const { clearable, readonly, focused, innerValue } = this;
|
||||
@@ -241,7 +249,15 @@ export default {
|
||||
style.paddingLeft = "9px";
|
||||
style.paddingRight = "9px";
|
||||
}
|
||||
return uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle));
|
||||
const mergedStyle = uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle));
|
||||
if (this.isSearchInput) {
|
||||
mergedStyle.height = '66rpx';
|
||||
mergedStyle.minHeight = '66rpx';
|
||||
mergedStyle.boxSizing = 'border-box';
|
||||
mergedStyle.paddingTop = '0';
|
||||
mergedStyle.paddingBottom = '0';
|
||||
}
|
||||
return mergedStyle;
|
||||
},
|
||||
// 输入框的样式
|
||||
inputStyle() {
|
||||
@@ -354,18 +370,49 @@ export default {
|
||||
flex: 1;
|
||||
|
||||
&--selectlike {
|
||||
/* 覆盖 inline style 的固定 height,让选择型模式高度自适应 */
|
||||
/* 覆盖 inline style 的固定 height,让普通选择型内容可自适应换行 */
|
||||
/* 短文字垂直居中,长文字撑开高度自动换行 */
|
||||
height: auto !important;
|
||||
min-height: 68rpx;
|
||||
|
||||
.u-input__content,
|
||||
.u-input__content__field-wrapper,
|
||||
/* 只让展示文本本身不抢事件,保留外层点击与 suffix 插槽事件 */
|
||||
.u-input__content__field-wrapper__field {
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
&--search-input {
|
||||
/* 列表页顶部查询框必须同高;该 class 在组件内部计算,兼容小程序组件样式隔离 */
|
||||
height: 66rpx !important;
|
||||
min-height: 66rpx;
|
||||
box-sizing: border-box;
|
||||
padding-top: 0 !important;
|
||||
padding-bottom: 0 !important;
|
||||
|
||||
.u-input__content,
|
||||
.u-input__content__field-wrapper {
|
||||
height: 100%;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.u-input__content__field-wrapper__field--selectlike {
|
||||
min-height: 0;
|
||||
line-height: 32rpx;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
word-break: normal;
|
||||
}
|
||||
|
||||
.u-input__content__field-wrapper__field__text,
|
||||
.u-input__content__field-wrapper__field__placeholder {
|
||||
line-height: 32rpx;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
|
||||
&--radius,
|
||||
&--square {
|
||||
border-radius: 4px;
|
||||
|
||||
Reference in New Issue
Block a user