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

193
Views
ifDefined no funciona en litElement

la pagina principal

 export class GdwcHeading extends LitElement { static get properties() { return { /** * Heading size */ size: { type: String }, /** * Heading level */ level: { type: String }, }; } render() { const styles = { fontSize: `var(${this.size})` }; const style = styleMap(styles); this.size = { fontSize: `var(${this.size})` }; this.sanitizeLevel(); return html` <${unsafeStatic(this.sanitizeLevel(this.level))} style=${style}><slot></slot></${unsafeStatic( this.sanitizeLevel(this.level) )}> `; } sanitizeLevel(level) { switch (this.level) { case `h1`: this.level = 'h1'; break; case `h3`: this.level = 'h3'; break; case `h4`: this.level = 'h4'; break; case `h5`: this.level = 'h5'; break; case `h6`: this.level = 'h6'; break; default: this.level = 'h2'; break; } return level; } }

la página de la historia

 import { html } from 'lit'; import { ifDefined } from 'lit/directives/if-defined.js'; import { controls, themeControls } from '../stories/fixtures/controls.js'; import '../heading.js'; import '../store.js'; import '../provider.js'; import '../stories/components/gdwc-theme.js'; export default { title: 'Elements/Heading', component: 'Heading', description: 'A simple heading component', parameters: { docs: { description: { component: 'A generic heading', }, }, }, argTypes: { defaultSlot: { table: { category: 'slots', }, }, size: { options: controls.sizes.options, control: controls.sizes.control, description: controls.sizes.description, table: { category: 'properties', }, }, level: { options: controls.headingLevels.options, control: controls.headingLevels.control, description: controls.headingLevels.description, table: { category: 'properties', }, }, ...themeControls, }, }; const Template = args => { const { size, defaultSlot, level } = args; return html` <gdwc-theme args=${JSON.stringify(args)}> <gdwc-heading ${ifDefined(size)} ${ifDefined(level)} >${defaultSlot}</gdwc-heading > </gdwc-theme>`; }; export const Primary = Template.bind({}); Primary.args = { defaultSlot: 'My Custom Heading', };

Por aquí, ifDefined debería representar la variable de nivel. pero se mantiene con el nivel 'h2' en la función sanitizeLevel es que cualquier problema en la función de nivel de desinfección. Por favor, intenta ayudarme con esto. Cualquier referencia a la función ifDefined es https://lit.dev/docs/templates/directives/#ifdefined

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Debe asignar los valores a los atributos.

 <gdwc-heading size="${ifDefined(size)}" level="${ifDefined(level)}"> ${defaultSlot} </gdwc-heading>
about 4 years ago · Juan Pablo Isaza 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!