-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
simultaneous use default script and script setup cause compile error #4376
Comments
export default input: <template>
</template>
<script lang="ts" setup>
// do something
</script>
<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
name: "MyComponent"
})
</script> generated: import { defineComponent as _defineComponent } from 'vue'
const __sfc__ = _defineComponent({
...__default__, // <-- ReferenceError: can't access lexical declaration '__default__' before initialization
setup(__props) {
// do something
return (_ctx,_cache) => {
return null
}
}
})
import { defineComponent } from 'vue'
const __default__ = defineComponent({
name: "MyComponent"
})
__sfc__.__file = "Comp.vue"
export default __sfc__ |
This is mentioned in the RFC |
why it works well in js, and only |
https://github.com/vuejs/rfcs/blob/script-setup/active-rfcs/0000-script-setup.md |
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
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 特性,如果将它们的书写顺序颠倒过来会导致浏览器抛出错误,但在启动服务时不会出现问题
The text was updated successfully, but these errors were encountered: