docs_vue2/one/docs/demo/search-box/suggestion.vue

79 lines
1.5 KiB
Vue
Raw Normal View History

2020-08-13 11:47:56 +08:00
<template>
<article>
<veui-search-box
v-model="value"
clearable
:suggestions="suggestions"
replace-on-select
@select="handleSelect"
/>
<veui-search-box
v-model="value1"
2020-09-22 11:06:13 +08:00
ui="strong"
2020-08-13 11:47:56 +08:00
clearable
:suggestions="suggestions1"
replace-on-select
@select="handleSelect"
/>
</article>
</template>
<script>
import { SearchBox } from 'veui'
import toast from 'veui/managers/toast'
export default {
components: {
'veui-search-box': SearchBox
},
data () {
return {
value: '',
value1: '',
browsers: [
'Google Chrome',
'Apple Safari',
'Microsoft Edge',
'Mozilla Firefox',
'Opera',
'Vivaldi',
'Internet Explorer',
'Maxthon',
'Android Browser',
'UC Browser',
'Samsung Internet',
'QQ Browser'
]
}
},
computed: {
suggestions () {
if (!this.value) {
return []
}
return this.browsers.filter(browser => {
return browser.toLowerCase().indexOf(this.value.toLowerCase()) !== -1
})
},
suggestions1 () {
if (!this.value1) {
return []
}
return this.browsers.filter(browser => {
return browser.toLowerCase().indexOf(this.value1.toLowerCase()) !== -1
})
}
},
methods: {
handleSelect ({ value }) {
toast.info(value)
}
}
}
</script>
2020-09-22 11:06:13 +08:00
<style lang="less" scoped>
2020-08-13 11:47:56 +08:00
.veui-search-box {
margin-left: 1em;
}
</style>