P
P
postya2020-12-30 19:48:07
Vue.js
postya, 2020-12-30 19:48:07

Why doesn't styling for slots work in Vue?

The Vue 3 application
has a child component. It has a slot, in this slot I will place several tags in the parent component.
Why doesn't styling work for each of the elements in slot in the child component?

Child component:

<template>
  <div>
    <slot></slot>
  </div>
</template>

<script>
export default {
  name: "SnippetItem"
};
</script>

<style scoped>
.snippet-item p {
  color: red;
}
</style>

Главный компонент:
<code>
 <SnippetItem>
          <div class="snippet-item">
            <h3>Title</h3>
            <p>Description</p>
            <div class="tags">
              <span>Frontend</span>
            </div>
          </div>
        </SnippetItem>
</code>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question