vue focus和blur事件,改变选中时搜索框的背景色
template<div class="search-box" ref="searchBoxOfChatRoom"><i class="fa fa-search" aria-hidden="true"></i><inputref="searchOfChatRoom"class="chatroom-search"type="sea...
·
template
<div class="search-box" ref="searchBoxOfChatRoom">
<i class="fa fa-search" aria-hidden="true"></i>
<input
ref="searchOfChatRoom"
class="chatroom-search"
type="search"
placeholder="搜索群成员"
@focus="changBackground(1)"
@blur="changBackground(2)"
>
</div>
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
}
}
更多推荐
已为社区贡献27条内容
所有评论(0)