遵循 Vuejs 和 Pinia 的设置指南
<script setup>
import {useStore} from "../stores/store.js";
export default {
setup() {
const store = useStore();
return {
store,
}
},
}
</script>
Run Code Online (Sandbox Code Playgroud)
我从 Vite 收到以下错误:
[vite] Internal server error: [@vue/compiler-sfc] <script setup> cannot contain ES module exports. If you are using a previous version of <script setup>, please consult the updated RFC at https://github.com/vuejs/rfcs/pull/227.
Run Code Online (Sandbox Code Playgroud)
<script setup>我如何迁移到允许我执行上述操作的版本?
谢谢!
Ari*_*Ari 55
我这边似乎有点困惑。这些文档讨论了添加<script setup>,然后还演示了使用setup(){},但他们没有明确说明其中之一。
方法一:
<script setup>
import {useStore} from "../stores/store.js";
const store = useStore();
// do stuff
</script>
Run Code Online (Sandbox Code Playgroud)
方法二:
<script>
import { defineComponent } from 'vue'
import {useStore} from "../stores/store.js";
export default defineComponent({
setup() {
const store = useStore();
// do stuff
return {
store,
}
}
})
</script>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
39471 次 |
| 最近记录: |