Laravel  
laravel
文档
数据库
架构
入门
php技术
    
Laravelphp
laravel / php / java / vue / mysql / linux / python / javascript / html / css / c++ / c#

vue :deep

作者:资本principal   发布日期:2025-06-18   浏览:19

<template>
  <div class="parent">
    <child-component></child-component>
  </div>
</template>

<script>
import ChildComponent from './ChildComponent.vue';

export default {
  components: {
    ChildComponent
  }
};
</script>

<style scoped>
.parent :deep(.child-class) {
  color: red;
}
</style>

解释说明:

  • :deep() 是 Vue 3 中用于在 scoped 样式中选择子组件元素的选择器。
  • 在上面的代码中,.parent 是父组件中的一个类,而 .child-class 是子组件中的一个类。
  • 使用 :deep(.child-class) 可以让父组件中的样式穿透到子组件中的元素,从而将 .child-class 的文本颜色设置为红色。

上一篇:vue 绑定class

下一篇:vue双向数据绑定

大家都在看

vue.config.js configu

node.js vue

vue查看版本

vue等待几秒

vue3 setup computed

vue screenfull

vue json.stringify

vue 遍历list

typescript vue

vue 复选框

Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3

Laravel 中文站