codesandbox-client icon indicating copy to clipboard operation
codesandbox-client copied to clipboard

Errors are reported when using vue3 template setup

Open jerrywu001 opened this issue 2 years ago • 7 comments

Bug report

Packages affected

  • [👉🏽 ] sandpack-react

Description of the problem

Errors are reported when using vue3 template setup

<Sandpack template="vue3"  />
<template>
  <main id="app">
    <h1>{{ helloWorld }}</h1>
  </main>
</template>
                             
<script setup>
const helloWorld = ref("Hello World");
</script>

image

jerrywu001 avatar Jun 01 '22 09:06 jerrywu001

@DeMoorJasper, it seems that given the following template, which includes the tags template, script, and style. But if you try to remove the style tag, it breaks something.

Sandbox: https://codesandbox.io/s/sandpack-project-forked-x9zfmb?file=/src/App.vue

danilowoz avatar Jun 06 '22 13:06 danilowoz

There is another problem: using setup on the script tag, the console reports an error. And no results are displayed in the preview area.

<template>
  <main id="app">
    <h1>{{ helloWorld }}</h1>
  </main>
</template>
                             
<script setup>
const helloWorld = ref("Hello World");
</script>

image

jerrywu001 avatar Jun 07 '22 01:06 jerrywu001

@danilowoz no I think the key problem is Vue new feature setup script, by which developer can use all composition API like ref、onMounted directly after adding the seup attribute for script tag without import anything. probably environment should move form vue-cli to @vue/cli

uyarn avatar Jun 08 '22 06:06 uyarn

Had the same issue today. Blocker for me to use codesandbox more frequently.

Theiaz avatar Jun 17 '22 10:06 Theiaz

same issue.

holazz avatar Jul 27 '22 09:07 holazz

<script setup> seems impossible to use with codesandbox. I hope this gets more attention as its becoming a more and more popular way to write components with Vue 3

Yoduh avatar Aug 25 '22 15:08 Yoduh

same issue

dojo-coder avatar Aug 31 '22 15:08 dojo-coder

same issue

xiangrikuil avatar Oct 25 '22 06:10 xiangrikuil

I wonder why this is still not working

LowLifeArcade avatar Nov 20 '22 03:11 LowLifeArcade

Looking forward to the support of vue3 syntax sugar <script setup>. At present, I have to convert my code by setup()

zymbth avatar Nov 25 '22 06:11 zymbth

您好,邮件已收到,谢谢!

zymbth avatar Nov 30 '22 09:11 zymbth

We just merged a fix that address:

  • Error on deleting a script or style tag;
  • Support for <script setup>;

Here's a sandbox: https://codesandbox.io/s/charming-turing-oe2n17?file=/src/App.vue

Could someone please confirm that it's working?

danilowoz avatar Nov 30 '22 10:11 danilowoz

We just merged a fix that address:

  • Error on deleting a script or style tag;
  • Support for <script setup>;

Here's a sandbox: https://codesandbox.io/s/charming-turing-oe2n17?file=/src/App.vue

Could someone please confirm that it's working?

When will it be released?

jerrywu001 avatar Nov 30 '22 10:11 jerrywu001

It should already be live on CodeSandbox and [email protected]

danilowoz avatar Nov 30 '22 10:11 danilowoz