element-plus的el-input如何去除聚焦时候的蓝色边框
以下代码无效
<script setup lang="ts">
import { ElementPlus } from '@element-plus/icons-vue'
import { version as epVersion } from 'element-plus'
import { ref, version as vueVersion } from 'vue'
const msg = ref('Hello World!')
</script>
<template>
<h1>{{ msg }}</h1>
<el-input v-model="msg" class="custom-input" :input-style="{
outline: 'none',
}" />
<p>
<el-icon color="var(--el-color-primary)"><ElementPlus /></el-icon>
Element Plus {{ epVersion }} + Vue {{ vueVersion }}
</p>
</template>
<style>
::deep(.el-input__inner):focus {
outline: none;
}
input:focus { outline: none; }
:deep(.el-input__inner) {
--el-input-focus-border-color: transparent;
--el-input-focus-outline: none;
}
:deep(.el-input__inner:focus) {
border-color: transparent;
box-shadow: none;
}
:deep(.custom-input .el-input__inner:focus) {
border-color: transparent;
box-shadow: none;
}
:deep(.el-input__wrapper){
box-shadow: none;
}
</style>
尝试过多种方式,但是没有效果,请看在线示例
在 Element Plus 中,
el-input
的聚焦边框是通过box-shadow
实现的,而不是传统的border
。需要重写.el-input__wrapper
的聚焦状态样式。