今日分享(1)

28 阅读1分钟

vue3项目中使用ts,

<script setup lang="ts"> export default { setup() { const a = ref('1') } <script>

这样写会报错,<script setup> cannot contain ES module exports. If you are using a previous version of <script setup> 中文意思内部服务错误,:[@vue/compiler-sfc] <script setup> 不能包含 ES 模块导出。如果您正在使用 <script setup>,请更新版本。

原因:其实问题就出在,官方文档提供了两种写法,我们把这两种写法混用了,

一种是:<script> 标签里面配置 setup

另一种是:export default 类里配置 setup() 方法

我们只需要使用一种方法即可,混用了就会报错了。