D
D
Dmitry2021-04-23 11:25:43
Vue.js
Dmitry, 2021-04-23 11:25:43

Vue 3 experimental attr vars in style not working?

Hello. I'm picking vue 3. I really liked the new feature with the ability to pass data to a block with styles in single-file components.

Decided to use this in my project and something went wrong.
We have a component

export default {
  props: {
    val: {
      type: String,
      default: '100px'
    }
  }
}


And the style block
<style vars="{ val }" scoped>
  .el {
    height: var(--val);
  }
</style>


This design doesn't work. In the inspector, an entry of the form style="--f948061a-val:40px;" is added to the element.
But the property is not applied, because the id scoped is not specified for the css variable (var(--val)).
If you remove scoped from style, then everything works. Has this been fixed? Previously,

vue 3.0.0 seemed to work

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