You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vue 2.6.11中使用:deep(.className)无效,是否不支持该语法?

问题解答

你遇到的情况是Vue 2.6.11确实不支持:deep()语法,不是操作有误。

  • Vue 2中深度选择器的标准写法是::v-deep(你原本能正常运行的写法),也可使用早期的/deep/(部分CSS预处理器兼容,但官方优先推荐::v-deep)
  • :deep()是Vue 3才引入的新语法,Vue 2的所有版本都不支持这种写法,所以你改成:deep(.v-alert__border)后样式无法生效

如果想继续在Vue 2.6.11中使用深度选择器,只能保持原来的::v-deep写法:

.alert {
  ::v-deep .v-alert__border {
    top: 8px;
    bottom: 8px;
    border-radius: 200px;
  }
  &:not(&--rtl) {
    // styles
  }
}

内容的提问来源于stack exchange,提问作者Ascolon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 21:01:05