|
|
@@ -10,14 +10,12 @@ Search bar
|
|
|
import { createApp } from 'vue';
|
|
|
|
|
|
// vue
|
|
|
-import { Searchbar, Icon } from '@nutui/nutui';
|
|
|
+import { Searchbar } from '@nutui/nutui';
|
|
|
// taro
|
|
|
-import { Searchbar, Icon } from '@nutui/nutui-taro';
|
|
|
+import { Searchbar } from '@nutui/nutui-taro';
|
|
|
|
|
|
const app = createApp();
|
|
|
app.use(Searchbar);
|
|
|
-app.use(Icon);
|
|
|
-
|
|
|
```
|
|
|
|
|
|
### Basic Usage
|
|
|
@@ -74,17 +72,45 @@ app.use(Icon);
|
|
|
|
|
|
### Display search Icon
|
|
|
:::demo
|
|
|
-```html
|
|
|
+````html
|
|
|
<template>
|
|
|
<nut-searchbar v-model="searchValue">
|
|
|
<template v-slot:leftin>
|
|
|
- <nut-icon size="14" name="search2"></nut-icon>
|
|
|
+ <Search2 />
|
|
|
+ </template>
|
|
|
+ </nut-searchbar>
|
|
|
+</template>
|
|
|
+<script lang="ts">
|
|
|
+import { toRefs, reactive } from 'vue';
|
|
|
+import { Search2 } from '@nutui/icons-vue';
|
|
|
+export default {
|
|
|
+ components: { Search2 },
|
|
|
+ setup() {
|
|
|
+ const state = reactive({
|
|
|
+ searchValue: ""
|
|
|
+ });
|
|
|
+
|
|
|
+ return {
|
|
|
+ ...toRefs(state),
|
|
|
+ };
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+```
|
|
|
+:::
|
|
|
+
|
|
|
+### Add search text to the right
|
|
|
+:::demo
|
|
|
+```html
|
|
|
+<template>
|
|
|
+ <nut-searchbar v-model="searchValue">
|
|
|
+ <template v-slot:rightout>
|
|
|
+ Search
|
|
|
</template>
|
|
|
</nut-searchbar>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
import { toRefs, reactive } from 'vue';
|
|
|
- import { Icon } from '@nutui/nutui';
|
|
|
export default {
|
|
|
setup() {
|
|
|
const state = reactive({
|
|
|
@@ -100,15 +126,11 @@ app.use(Icon);
|
|
|
```
|
|
|
:::
|
|
|
|
|
|
-### Add search text to the right
|
|
|
+### Change the background style inside and outside the input box
|
|
|
:::demo
|
|
|
```html
|
|
|
<template>
|
|
|
- <nut-searchbar v-model="searchValue">
|
|
|
- <template v-slot:rightout>
|
|
|
- 搜索
|
|
|
- </template>
|
|
|
- </nut-searchbar>
|
|
|
+ <nut-searchbar v-model="searchValue" background="linear-gradient(to right, #9866F0, #EB4D50)" input-background="#fff"> </nut-searchbar>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
import { toRefs, reactive } from 'vue';
|
|
|
@@ -127,51 +149,62 @@ app.use(Icon);
|
|
|
```
|
|
|
:::
|
|
|
|
|
|
-### Change the background style inside and outside the input box
|
|
|
+### Custom Clear Button icon
|
|
|
+
|
|
|
:::demo
|
|
|
```html
|
|
|
<template>
|
|
|
- <nut-searchbar v-model="searchValue4" background="linear-gradient(to right, #9866F0, #EB4D50)" input-background="#fff"> </nut-searchbar>
|
|
|
+ <nut-searchbar v-model="searchValue">
|
|
|
+ <template v-slot:clearIcon>
|
|
|
+ <img :src="icon" style="width: 10px; height: 10px" />
|
|
|
+ </template>
|
|
|
+ </nut-searchbar>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
import { toRefs, reactive } from 'vue';
|
|
|
export default {
|
|
|
setup() {
|
|
|
+ const icon =
|
|
|
+ 'https://img10.360buyimg.com/imagetools/jfs/t1/170133/30/22902/10546/61833626E32d7ccde/a7c373ba30de9a89.png';
|
|
|
const state = reactive({
|
|
|
searchValue: ""
|
|
|
});
|
|
|
|
|
|
return {
|
|
|
...toRefs(state),
|
|
|
+ icon
|
|
|
};
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
```
|
|
|
:::
|
|
|
+
|
|
|
+
|
|
|
### Show all icons
|
|
|
:::demo
|
|
|
```html
|
|
|
<template>
|
|
|
<nut-searchbar v-model="searchValue">
|
|
|
<template v-slot:leftout>
|
|
|
- <nut-icon @click="clickLeft" size="20" name="left"></nut-icon>
|
|
|
+ <Left @click="clickLeft" />
|
|
|
</template>
|
|
|
<template v-slot:leftin>
|
|
|
- <nut-icon size="14" name="search2"></nut-icon>
|
|
|
+ <Search2 />
|
|
|
</template>
|
|
|
<template v-slot:rightin>
|
|
|
- <nut-icon size="20" name="photograph"></nut-icon>
|
|
|
+ <Photograph />
|
|
|
</template>
|
|
|
<template v-slot:rightout>
|
|
|
- <nut-icon size="20" name="message"></nut-icon>
|
|
|
+ <Message />
|
|
|
</template>
|
|
|
</nut-searchbar>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
import { toRefs, reactive } from 'vue';
|
|
|
- import { Icon } from '@nutui/nutui';
|
|
|
+ import { Search2, Left, Photograph, Message } from '@nutui/icons-vue';
|
|
|
export default {
|
|
|
+ components: { Search2, Left, Photograph, Message },
|
|
|
setup() {
|
|
|
const state = reactive({
|
|
|
searchValue: ""
|