Skip to content

Commit 03623f4

Browse files
authored
feat: ✨ Search新增customInputClass,placeholderClass等属性 (#845)
Closes: #299
1 parent 7a0d5ce commit 03623f4

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

docs/component/search.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ function changeSearchType({ item, index }) {
155155
| ~~use-suffix-slot~~ | ~~是否使用输入框右侧插槽~~**(已废弃,将在下一个 minor 版本被移除,直接使用插槽即可)** | boolean | - | false | - |
156156
| focus | 是否自动聚焦 | boolean | - | false | 0.1.63 |
157157
| focusWhenClear | 是否在点击清除按钮时聚焦输入框 | boolean | - | false | 0.1.63 |
158+
| placeholderStyle | 原生属性,指定 placeholder 的样式,目前仅支持color,font-size和font-weight | string | - | - | $LOWEST_VERSION$ |
159+
| placeholderClass | 原生属性,指定 placeholder 的样式类 | string | - | - | $LOWEST_VERSION$ |
158160

159161
## Events
160162

@@ -179,3 +181,4 @@ function changeSearchType({ item, index }) {
179181
| 类名 | 说明 | 最低版本 |
180182
| ------------ | ---------- | -------- |
181183
| custom-class | 根节点样式 | - |
184+
| custom-input-class | input 外部自定义样式 | $LOWEST_VERSION$ |

src/uni_modules/wot-design-uni/components/wd-search/types.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { baseProps, makeBooleanProp, makeNumberProp, makeNumericProp, makeString
1111

1212
export const searchProps = {
1313
...baseProps,
14-
14+
customInputClass: makeStringProp(''),
1515
/**
1616
* 输入框内容,双向绑定
1717
* 类型: string
@@ -88,5 +88,15 @@ export const searchProps = {
8888
* 默认值: false
8989
* 最低版本: 0.1.63
9090
*/
91-
focusWhenClear: makeBooleanProp(false)
91+
focusWhenClear: makeBooleanProp(false),
92+
93+
/**
94+
* 原生属性,指定 placeholder 的样式,目前仅支持color,font-size和font-weight
95+
*/
96+
placeholderStyle: String,
97+
98+
/**
99+
* 原生属性,指定 placeholder 的样式类
100+
*/
101+
placeholderClass: makeStringProp('')
92102
}

src/uni_modules/wot-design-uni/components/wd-search/wd-search.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
<input
1212
v-if="showInput || str || placeholderLeft"
1313
:placeholder="placeholder || translate('search')"
14-
placeholder-class="wd-search__placeholder-txt"
14+
:placeholder-class="`wd-search__placeholder-txt', ${placeholderClass}`"
15+
:placeholder-style="placeholderStyle"
1516
confirm-type="search"
1617
v-model="str"
17-
class="wd-search__input"
18+
:class="['wd-search__input', customInputClass]"
1819
@focus="searchFocus"
1920
@input="inputValue"
2021
@blur="searchBlur"

0 commit comments

Comments
 (0)