parent
67b5a534fc
commit
ee86939942
@ -0,0 +1,56 @@ |
||||
<template> |
||||
<div class="aside-search"> |
||||
<el-input |
||||
v-model="value" |
||||
size="mini" |
||||
clearable |
||||
placeholder="搜索菜单" |
||||
prefix-icon="el-icon-search" |
||||
@input="search" |
||||
/> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import {debounce} from "@/util" |
||||
|
||||
export default { |
||||
name: "MenuSearch", |
||||
|
||||
data: () => ({value: ''}), |
||||
|
||||
methods: { |
||||
search(v) { |
||||
this.$emit('search', v) |
||||
} |
||||
}, |
||||
|
||||
created() { |
||||
this.search = debounce(this.search) |
||||
}, |
||||
|
||||
beforeDestroy() { |
||||
this.$emit('search', '') |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style lang="scss"> |
||||
@import "~@/asset/style/variables.scss"; |
||||
|
||||
//侧边栏折叠时不显示 |
||||
.collapse .aside-search { |
||||
display: none; |
||||
} |
||||
|
||||
.aside-search { |
||||
margin: 12px 8px; |
||||
} |
||||
|
||||
//暗色主题 |
||||
.dark .aside-search .el-input__inner { |
||||
border: none; |
||||
color: #ffffff; |
||||
background-color: lighten($menu-dark-background, 5%); |
||||
} |
||||
</style> |
||||
@ -0,0 +1,24 @@ |
||||
/** |
||||
* 侧边栏搜索框混入 |
||||
*/ |
||||
import MenuSearch from '@/layout/component/Aside/component/MenuSearch' |
||||
import {trim} from "@/util" |
||||
import {findComponentByTag} from "@/util/vue" |
||||
|
||||
export default { |
||||
components: {MenuSearch}, |
||||
|
||||
methods: { |
||||
$_getNavMenuInstance() { |
||||
if (!this.$_navMenuInstance) { |
||||
this.$_navMenuInstance = findComponentByTag(this, 'nav-menu') |
||||
} |
||||
|
||||
return this.$_navMenuInstance |
||||
}, |
||||
|
||||
handlerSearch(v) { |
||||
this.$_getNavMenuInstance().realSearchWord = trim(v) |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue