@@ -49,22 +49,26 @@ export default {
4949 message = { key: ' show-hide' }
5050 }
5151
52- if (message .key === ' show-hide' ) { // 显示/隐藏
53- this .hideSearchBar = message .hideSearchBar != null ? message .hideSearchBar : ! this .hideSearchBar
52+ try {
53+ if (message .key === ' show-hide' ) { // 显示/隐藏
54+ this .hideSearchBar = message .hideSearchBar != null ? message .hideSearchBar : ! this .hideSearchBar
5455
55- // 显示后,获取输入框焦点
56- if (! this .hideSearchBar ) {
57- setTimeout (() => {
58- try {
59- this .$refs .searchBar .$el .querySelector (' input' ).focus ()
60- } catch {
61- }
62- }, 100 )
56+ // 显示后,获取输入框焦点
57+ if (! this .hideSearchBar ) {
58+ setTimeout (() => {
59+ try {
60+ this .$refs .searchBar .$el .querySelector (' input' ).focus ()
61+ } catch {
62+ }
63+ }, 100 )
64+ }
65+ } else if (message .key === ' next' ) { // 下一项
66+ this .$refs .searchBar .next ()
67+ } else if (message .key === ' previous' ) { // 上一项
68+ this .$refs .searchBar .previous ()
6369 }
64- } else if (message .key === ' next' ) { // 下一项
65- this .$refs .searchBar .next ()
66- } else if (message .key === ' previous' ) { // 上一项
67- this .$refs .searchBar .previous ()
70+ } catch (e) {
71+ console .error (' 操作SearchBar出现异常:' , e)
6872 }
6973 })
7074 },
@@ -89,6 +93,7 @@ export default {
8993 :highlightClass =" 'search-bar-highlight'"
9094 :selectedClass =" 'selected-highlight'"
9195 :hiden.sync =" hideSearchBar"
96+ style =" top :auto ;right :auto ;left :160px ;bottom :52px ;background-color :#ddd "
9297 />
9398 <a-layout >
9499 <a-layout-sider :theme =" theme" >
@@ -180,9 +185,10 @@ body {
180185}
181186.search-bar-highlight {
182187 background-color : #ef0fff ;
188+ color : #fdfdfd ;
183189
184190 & .selected-highlight {
185- background-color : #38d878 ;
191+ background-color : #17a450 ;
186192 }
187193}
188194 </style >
0 commit comments