vue中scoped的使用
原理:
vue通过在DOM结构以及css样式上加上唯一的标记 data-v-469af010,保证唯一,
[ ] 概点知识
1.父组件无scoped属性,子组件带有scoped,父组件是无法操作子组件的样式的(原因在原理中可知),虽然我们可以在全局中通过该类标签的标签选择器设置样式,但会影响到其他组件
2.父组件有scoped属性,子组件无,父组件也无法设置子组件样式,因为父组件的所有标签都会带有data-v-469af010唯一标志,但子组件不会带有这个唯一标志属性,与1同理,虽然我们可以在全局中通过该类标签的标签选择器设置样式,但会影响到其他组件
3.父子组建都有,同理也无法设置样式,更改起来增加代码量
因此如果组件内部还有组件,只会给最外层的组件里的标签加上唯一属性字段,不影响组件内部引用的组件( 注意 )
-
使用方法
-
混合使用全局属性和局部属性
<style>
.el-button--small {
font-size: 12px !important;
}
.el-message-box__btns .el-button--small{
width:100px;
height: 32px;
background:white !important;
border-radius: 16px;
border:1px solid #DCDFE6;
color:#4c9aff;
font-weight: bold !important;
font-size: 20px !important;
line-height:10px !important;
}
.el-message-box__btns .el-button--small:hover{
border:1px solid #3680e4 !important;
color:#357FE3 !important;
}
.el-message-box__btns .el-button--primary{
height: 32px !important;
color: #FFF !important;
background-color: #409EFF !important;
border-color: #409EFF !important;
font-weight: bold;
font-size: 20px;
}
.el-message-box__btns .el-button--primary:hover{
color: #FFF !important;
background-color: #409EFF !important;
}
</style>
- 深选择器
<style scoped>
.el-select {
width: 160px;
height: 32px;
line-height: 32px;
}
.el-input__icon {
line-height: 34px;
position: relative;
/*left: 719%;*/
left:724%;
}
.el-select>.el-input {
display: block;
width: 160px;
}
.el-input {
font-size: 16px;
width: 240px;
height: 32px;
line-height: 32px;
border: none;
border-radius: 16px;
}
.el-input__inner {
height: 32px;
line-height: 32px;
border-radius: 16px;
background: #0B1339;
color: #FFFFFF;
border-color: #4A5278;
}
.el-table td,
.el-table th {
padding: 12px 0;
text-align: left;
color: white;
border: none;
}
.el-table__body tr:hover>td {
background-color:transparent !important;
}
.el-table th {
background-color: #142A59;
}
.el-table tr {
background: #091638;
}
.el-table th.is-leaf {
/* 去除上边框 */
border-bottom: none;
}
.el-table::before {
/* 去除下边框 */
height: 0;
}
.el-pagination {
color: #303133;
font-weight: 700;
width: 100%;
text-align: center;
margin: 30px 0 19px 0;
}
.el-pagination.is-background .btn-next,
.el-pagination.is-background .btn-prev,
.el-pagination.is-background .el-pager li {
margin: 0 5px;
background-color: #10173E;
color: white;
min-width: 30px;
border-radius: 2px;
border: 1px solid #2E4375;
/* border-color: #2E4375; */
}
.el-pagination__editor.el-input .el-input__inner {
border-radius: 4px;
}
.el-range-editor.el-input__inner {
display: -webkit-inline-box;
display: -ms-inline-flexbox;
display: inline-flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
padding: 0 13px;
border-color: #3F466C;
}
.el-range-editor .el-range-input {
line-height: 1;
background: #0D143A;
color: #3F466C;
}
.el-date-editor .el-range-separator {
padding: 0 5px;
line-height: 32px;
width: 5%;
color: #FDFFFF;
}
.el-drawer__body .el-input__inner {
height: 32px;
line-height: 32px;
border-radius: 16px;
background: white;
color: #5C5C5C;
border-color: #E5E5E5;
width:240px;
margin-left: -14px;
}
.el-drawer__body .el-input {
width: 160px !important;
}
.demo-drawer__footer {
text-align: center;
}
.examine {
-webkit-box-sizing: border-box;
box-sizing: border-box;
margin-left: 119px;
}
.el-timeline-item__timestamp.is-top {
/* margin-top: -16px; */
margin-left: -110px;
width: 100px;
color: black;
}
.el-timeline-item__content {
color: black;
margin-top: -38px;
}
.el-date-editor .el-range-separator {
padding: 0 5px;
line-height: 32px;
width: 10%;
color: #FDFFFF;
}
.inputLine .el-input__inner {
width: 455px;
margin-left: -14px;
}
</style>