已解决 - Vue 如何覆盖 element-ui 的 css 样式

问题描述

我正在尝试从 element-ui 覆盖输入框上的背景颜色 但从来没有工作过

<template>
<el-input v-model="form.text" type="text" clearable></el-input>
</template

<style lang="stylus" scoped>

.el-input__inner 
    background-color #f4f4f4

</style>

从样式中删除作用域

<style lang="stylus">

.el-input__inner 
    background-color #f4f4f4

</style>

基于我从 chrome 收集的信息

chrome dev tool snapshot

解决方法

第一个选项: 尝试覆盖

.el-input__inner { 
    background-color: #f4f4f4 !important;
}

第二个选项: 创建一个单独的 css 文件,在 element-ui 执行之后加载。