Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Style variables not working with TSX #3808

Closed
wenfangdu opened this issue May 21, 2021 · 7 comments
Closed

[Bug] Style variables not working with TSX #3808

wenfangdu opened this issue May 21, 2021 · 7 comments
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. 🐞 bug Something isn't working scope: sfc

Comments

@wenfangdu
Copy link

wenfangdu commented May 21, 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

@wenfangdu wenfangdu changed the title Style variables not working with TSX [Bug] Style variables not working with TSX May 21, 2021
@HcySunYang HcySunYang added 🐞 bug Something isn't working 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: sfc labels May 24, 2021
@wenfangdu
Copy link
Author

wenfangdu commented May 25, 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

@wenfangdu
Copy link
Author

Can anyone reopen this 🙏?

@HcySunYang
Copy link
Member

I will check it later

@HcySunYang
Copy link
Member

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

@wenfangdu
Copy link
Author

wenfangdu commented May 28, 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

@edison1105
Copy link
Member

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

@wenfangdu
Copy link
Author

@edison1105 Thanks for the tip!

@github-actions github-actions bot locked and limited conversation to collaborators Oct 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. 🐞 bug Something isn't working scope: sfc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants