Subscribe on changes!

[Bug] Style variables not working with TSX

avatar
May 21st 2021

Version

3.1.0-beta.3

Reproduction link

https://github.com/wenfangdu/vue-3-style-vars-tsx-repro

Steps to reproduce

Please see App.vue.

What is expected?

Works with TSX

What is actually happening?

Not working with TSX

avatar
May 25th 2021

compiler-sfc: support tsx in setup script (#3825) (01e8ba8), closes #3808

@yyx990803 I've tried v3.1.0-beta.4, still reproducible.

Repro: https://github.com/wenfangdu/vue-3-style-vars-tsx-repro

avatar
May 28th 2021

Can anyone reopen this 🙏?

avatar
May 28th 2021

I will check it later

avatar
May 28th 2021

@wenfangdu Can't reproduce, maybe you need to reinstall the deps to make sure you really update the deps

avatar
May 28th 2021

@HcySunYang I've tried deleting node_modules and package.json and updated vue to v3.1.0-beta.5, still reproducible.

I've updated repro to reflect this:

<!-- 👇 works -->
<script lang="ts">
  import { defineComponent, h } from 'vue'

  export default defineComponent({
    data() {
      return {
        color: 'red',
        font: {
          size: '2em',
        },
      }
    },
    setup() {
      return () => h('div', { class: 'text' }, 'hello')
    },
  })
</script>

<!-- 👇 works -->
<script>
  import { defineComponent } from 'vue'

  export default defineComponent({
    data() {
      return {
        color: 'red',
        font: {
          size: '2em',
        },
      }
    },
    setup() {
      return () => <div class='text'>hello</div>
    },
  })
</script>

<!-- 👇 does not work -->
<script lang="tsx">
  import { defineComponent } from 'vue'

  export default defineComponent({
    data() {
      return {
        color: 'red',
        font: {
          size: '2em',
        },
      }
    },
    setup() {
      return () => <div class='text'>hello</div>
    },
  })
</script>

<style>
  body {
    background: #000;
    text-align: center;
  }

  .text {
    color: v-bind(color);

    /* expressions (wrap in quotes) */
    font-size: v-bind('font.size');
  }
</style>

Just a black screen:

image

If it works, it should show:

image

avatar
May 28th 2021

@wenfangdu you should also update @vue/compiler-sfc image

avatar
May 28th 2021

@edison1105 Thanks for the tip!