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
  }
}
Logo

前往低代码交流专区

更多推荐