Vue中的@blur/@focus事件怎么使用
Vue的@blur/@focus事件
@blur
是当元素失去焦点时所触发的事件@focus
是元素获取焦点时所触发的事件
focus和blur事件,改变选中时搜索框的背景色
template
js
changBackground (flag) { switch (flag) { case 1: console.log('获取焦距') this.$refs.searchBoxOfChatRoom.style.background = 'white' this.$refs.searchOfChatRoom.style.background = 'white' break case 2: console.log('失去焦距') this.$refs.searchBoxOfChatRoom.style.background = '#dadada' this.$refs.searchOfChatRoom.style.background = '#dadada' break default: break } }