mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
51 lines
760 B
Vue
51 lines
760 B
Vue
<template>
|
|
<div id="docsearch" />
|
|
</template>
|
|
|
|
<script>
|
|
import '@docsearch/css';
|
|
import docsearch from '@docsearch/js';
|
|
|
|
export default {
|
|
name: 'van-doc-search',
|
|
|
|
props: {
|
|
lang: String,
|
|
searchConfig: Object,
|
|
},
|
|
|
|
watch: {
|
|
lang() {
|
|
this.initDocsearch();
|
|
},
|
|
},
|
|
|
|
mounted() {
|
|
this.initDocsearch();
|
|
},
|
|
|
|
methods: {
|
|
initDocsearch() {
|
|
if (this.searchConfig) {
|
|
docsearch({
|
|
...this.searchConfig,
|
|
container: '#docsearch',
|
|
searchParameters: {
|
|
facetFilters: [`lang:${this.lang}`],
|
|
},
|
|
});
|
|
}
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style lang="less">
|
|
@import '../../common/style/var';
|
|
|
|
#docsearch {
|
|
display: inline-block;
|
|
vertical-align: middle;
|
|
}
|
|
</style>
|