Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

267
Views
vue: estilo no aplicado para componente adicional en el mismo archivo

Agregué algo de estilo en .title y .description en mi hoja de estilo para mi componente de test , pero no estoy seguro de por qué no se aplicó el estilo.

 const test = Vue.component("test", { template: `<div class="test"> <span class="title">{{title}}</span> <div class="description">{{description}}</div> </div>`, props: { id: Number, title: String, description: String, }, });

ingrese la descripción de la imagen aquí

HolaMundo.vue

 <template> <div id="hello"> <test v-for="item in steps" :key="item.id" :id="item.id" :title="item.title" :description="item.description" /> </div> </template> <script> import Vue from "vue"; const test = Vue.component("test", { template: `<div class="test"> <span class="title">{{title}}</span> <div class="description">{{description}}</div> </div>`, props: { id: Number, title: String, description: String, }, }); export default { components: { test, }, data() { return { steps: [ { id: 1, title: "What is Lorem Ipsum?", description: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.", }, ], }; }, }; </script> <style scoped lang="scss"> #hello { display: flex; flex-direction: column; .test { /* style applied */ text-align: left; margin-top: 10px; .title { /* style not applied */ font-size: 50px; color: orange; } .description { /* style not applied */ font-size: 10px; line-height: 12px; color: red; } } } </style>

Códigosycaja:
https://codesandbox.io/s/amazing-flower-rcvob?file=/src/components/HelloWorld.vue

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Al usar estilos con alcance, los estilos solo se aplicarán a los elementos directos en la plantilla correspondiente. Los elementos de title y description son elementos secundarios del componente <test> y no se ven afectados por los estilos de ámbito de otro componente.

Debe usar ::v-deep si desea que el estilo se aplique a un elemento secundario de otro componente:

 #hello { .test { &::v-deep .title { color: red; } } }

Sin embargo, no pude hacer que esto funcionara en codesandbox. Puede ser un problema de configuración. Consulte también Selectores profundos .

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!