关于 vue3运行报错Internal server error: [@vue/compiler-sfc] <script setup> cannot contain ES 的处理方法

大致的意思就是 script setup  不能使用ES模块导出

其实问题就出在,给官方给出的方法混用了

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

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

两者用一种就行了

第一种 

<script setup>
import {useStore} from "../stores/store.js";
const store = useStore();
</script>

第二种

<script>
import { defineComponent } from 'vue'
import {useStore} from "../stores/store.js";
export default defineComponent({
  setup() {
    const store = useStore();
    return {
      store,
    }
  }
})
</script>

猜你喜欢

转载自blog.csdn.net/k490031/article/details/129727265