Although the default style has been able to meet many needs when usingelement-ui
, there are always some custom needs to be added sometimes. However, sometimes the style is written on it, which should be correct in theory, but it does not take effect.
In fact, when vue
using a third-party framework in a project, this problem may occur. The reason is vue
that it scoped
can be declared that the style is effective within the scope of the component. So as to avoid style pollution of different components, but most people write with scoped
them, so the style scoped
does not take effect in the domain.
Solution:
1. Remove scoped
Directly <style lang="less" scoped>
in scoped
to remove it so that style to take effect, although simple and crude but it is not a good method.
2. Use deep action selectors
Used >>>
as a deep-action selector in css
<style scoped> .box >>> .el-input { width: 60px; } </style>
Used /deep/
as a deep-action selector in less
<style lang= "less" scoped> .avatar-uploader /deep/ .el-upload { border: 1px dashed # d9d9d9; border-radius: 6px; cursor: pointer; } </style>
3. Use global styles
Define a global style, such as global.css
, and then main.js
import it in, so that this style is globally mounted, and the custom styles written in it will also take effect.
Read More:
- [Solved] Custom components with click events do not work
- Use of error attribute in element UI (solution of triggering only once)
- [Solved] VUE D:\project\vueProject\vue-02\src\components\hello.vue 5:5 error Parsing error: x-invalid-end-tag
- Vue wran name Error: Unkown custom element [How to Solve]
- [Solved] Vue element UI form verification error: cannot read property ‘validate’ of undefined
- [Solved] Vue3 Import element UI error: Uncaught TypeError: Cannot read properties of underfined…
- [Solved] Vue3.0 Error: The component has been registered but not used vue/no-unused-components, Close eslint
- [Solved] ant design pro vue Startup Error: ERROR Failed to compile with 1 error 20:34:09 error in ./src/components/Num
- [Solved] Front end error: Unknown custom element
- Vue Import element-plus Error: Failed to resolve import “element-pluslibtheme-chalkindex.css“ from “src
- Solution to build error in Vue project (error in static/JS)/vendor.xxxxx.js from UglifyJs)
- Vue warn]: vue3 element Component emit Pass Event Error
- [Solved] Vue Element Date plug-in reports an error in form validation
- [Solved] Vue Project Error: Arrow function should not return assignment
- How to Solve Vue add element Install Error
- Vue3.0 error: Failed to resolve component el-form-item (el element to be unable to be displayed)
- [Solved] Vue3 Configuration routing error: Catch all routes (“*“) must now be defined using a param with a custom regexp.
- Vue element component V-for error [How to Modify)
- [Solved] ERROR in ./node_modules/element-ui/lib/theme-chalk/fonts/element-icons.ttf
- React project is packaged and set as required Error [How to Solve]