the >>> and /deep/ combinators have been deprecated. Use :deep() instead终端报该警告的解决办法

一. 项目环境

项目版本是vue3.0

二. 报出的警告
2.1当css样式为这样写时
<style lang="less" scoped>
/deep/ .ant-table-tbody > tr > td,
/deep/ .ant-table-thead > tr > th {
	vertical-align: middle !important;
}
</style>

终端报以下警告:

the >>> and /deep/ combinators have been deprecated. Use :deep() instead终端报该警告的解决办法_第1张图片

2.1当css样式为这样写时:
<style lang="less" scoped>
// 第一种
::v-deep .ant-table-tbody > tr > td,
::v-deep .ant-table-thead > tr > th {
	vertical-align: middle !important;
}
// 第二种
:deep .ant-table-tbody > tr > td,
:deep .ant-table-thead > tr > th {
	vertical-align: middle !important;
}
</style>

终端均会报以下警告:

the >>> and /deep/ combinators have been deprecated. Use :deep() instead终端报该警告的解决办法_第2张图片

二. 解决办法

以下四种写法均不会报出警告。

<style lang="less" scoped>
// 第一种
:v-deep .ant-table-tbody > tr > td,
:v-deep .ant-table-thead > tr > th {
	vertical-align: middle !important;
}
// 第二种
::v-deep(.ant-table-tbody > tr > td),
::v-deep(.ant-table-thead > tr > th) {
	vertical-align: middle !important;
}
// 第三种
:v-deep(.ant-table-tbody > tr > td),
:v-deep(.ant-table-thead > tr > th) {
	vertical-align: middle !important;
}
// 第四种
:deep(.ant-table-tbody > tr > td),
:deep(.ant-table-thead > tr > th) {
	vertical-align: middle !important;
}
</style>

(完)

---------------------------------------- 补充 ----------------------------------------

如下所示,我的穿透格式写错了

:deep .ant-select-selector {
	height: 30px !important;
}

但是依然报了这个警告:

the >>> and /deep/ combinators have been deprecated. Use :deep() instead终端报该警告的解决办法_第3张图片
我全局找::v-deep,可是都没结果,如下:

the >>> and /deep/ combinators have been deprecated. Use :deep() instead终端报该警告的解决办法_第4张图片
排查了半天才找到问题:更改了写错的代码后就不再报这个警告了

// 写错代码:
:deep .ant-select-selector {
	height: 30px !important;
}

// 更改后
:deep(.ant-select-selector) {
	height: 30px !important;
}

你可能感兴趣的:(vue3.0,CSS,vue)