Subscribe on changes!

import without new line at the top of setup script + defineProps causes error

avatar
Oct 8th 2021

Version

3.2.19

Reproduction link

sfc.vuejs.org/

Steps to reproduce

  • open the repro

What is expected?

const props = __props; import { ref } from 'vue'

What is actually happening?

编译成的代码: const props = __propsimport { ref } from 'vue'


第一句import那里如果不换号就会出错,vue文件会编译成 ......props=propsimport { reactive,ref} ......,应该是少一个";" 如果import那句换行的话,就不会出错了

avatar
Oct 8th 2021

There is no error

avatar
Oct 8th 2021
<script setup>import { ref } from 'vue' // this line will cause an error
 const props=defineProps({
   foo:String
 })

const msg = ref('Hello World!')
</script>

<template>
  <h1>{{ msg }}</h1>
  <input v-model="msg">
</template>
avatar
Oct 8th 2021

Thanks @edison1105 It's weird the error didn't show when I opened the repro 🤔