建设网站的公司汇总,企业年金辞职了怎么办,有没有做网站,济南做网站的公司哪家好前言#xff1a;当我们用 vue3 :deep() 处理 elementui 中 el-dialog_body和el-dislog__header 的时候样式一直无法生效#xff0c;遇到这种情况怎么办#xff1f; 解决办法#xff1a;
1.直接在 dialog 上面增加class 我试过#xff0c;也不起作用#xff0c;最后用这种… 前言当我们用 vue3 :deep() 处理 elementui 中 el-dialog_body和el-dislog__header 的时候样式一直无法生效遇到这种情况怎么办 解决办法
1.直接在 dialog 上面增加class 我试过也不起作用最后用这种方法解决的dialog 外面直接包一层 div
2.将样式单独写一个style标签进行覆盖---此方式由于样式写在外面可能会影响整个项目的全局样式--慎重考虑需求需要将el-drawer__header的底部的外边距去掉 方式一 修改前 修改后 生效方式1.在最外层加一层在el-dialog外面包一层 2.主要是vue3中deep会因为最外层没有根节点失效的问题只需要加一个根节点deep就有效了 需要注意的是 :deep(这里面只能包一个) templatediv classdialogel-drawer v-modeldrawerDialog directionrtl closehandleClose size50%template #headerdiv classheaderh4订单详情----订单编号(23232434343)/h4/div/templatetemplate #defaultdiv classcontentdiv classitem-infodiv classwrapdiv classtopdiv classleftdiv classline/divdiv classtitle购方信息/div/divdiv classrightel-button typeprimary plain编辑/el-button/div/divdiv classinfo-list/div/div/div/div/templatetemplate #footerdiv styleflex: autoel-button clickhandleClose取消/el-buttonel-button typeprimary clickconfirm确定/el-button/div/template/el-drawer/div
/templatescript setup
import { watchEffect, ref } from vue;
const emit defineEmits([close])
const props defineProps({visible: {type: Boolean,default: false}
})
const drawerDialog ref(false);//确定的回调函数
const confirm () {}//取消的回调函数
const handleClose () {drawerDialog.value false;emit(close);
}watchEffect(() {if (props.visible) {drawerDialog.value props.visible;}
})/scriptstyle scoped langscss
.dialog {:deep(.el-drawer__header) {margin: 0;}
}.header {background-color: #fff;height: 40px;
}.content {background-color: #EDEFEE;.item-info {.wrap {.top {display: flex;justify-content: space-between;.left {display: flex;align-items: center;.line {height: 15px;width: 4px;background-color: #07f;}.title {font-size: 16px;font-weight: bold;}}.right {}}.info-list {}}}
}
/style方式二
template el-drawer v-modeldrawerDialog directionrtl closehandleClose size50%template #headerdiv classheaderh4订单详情----订单编号(23232434343)/h4/div/templatetemplate #defaultdiv classcontentdiv classitem-infodiv classwrapdiv classtopdiv classleftdiv classline/divdiv classtitle购方信息/div/divdiv classrightel-button typeprimary plain编辑/el-button/div/divdiv classinfo-list/div/div/div/div/templatetemplate #footerdiv styleflex: autoel-button clickhandleClose取消/el-buttonel-button typeprimary clickconfirm确定/el-button/div/template/el-drawer
/templatescript setup
import { watchEffect, ref } from vue;
const emit defineEmits([close])
const props defineProps({visible: {type: Boolean,default: false}
})
const drawerDialog ref(false);//确定的回调函数
const confirm () {}//取消的回调函数
const handleClose () {drawerDialog.value false;emit(close);
}watchEffect(() {if (props.visible) {drawerDialog.value props.visible;}
})/scriptstyle
.el-drawer__header {margin: 0;
}
/style
style scoped langscss.header {background-color: #fff;height: 40px;
}.content {background-color: #EDEFEE;.item-info {.wrap {.top {display: flex;justify-content: space-between;.left {display: flex;align-items: center;.line {height: 15px;width: 4px;background-color: #07f;}.title {font-size: 16px;font-weight: bold;}}.right {}}.info-list {}}}
}
/style修改前 修改后