Skip to content

simultaneous use default script and script setup cause compile error #4376

@PiscineMolitorPatel

Description

@PiscineMolitorPatel

Version

3.2.4

Reproduction link

https://github.com/vuejs/rfcs/blob/master/active-rfcs/0040-script-setup.md#detailed-design

Steps to reproduce

I must use <script> frist,then use <script setup>, Otherwise it will throw an error.

If I use it like this,the browser will give an error :Cannot access 'default' before initialization

<script lang="ts" setup>
// do something
</script>

<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
  name: '"MyComponent"
})
</script>

What is expected?

no error

What is actually happening?

Error: Cannot access 'default' before initialization


my english is not good, I use translation

中文说明:当我同时使用 script 和 script setup 时,我必须优先使用默认的 script,然后使用 script setup 特性,如果将它们的书写顺序颠倒过来会导致浏览器抛出错误,但在启动服务时不会出现问题

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions