How to use spread operator in <script setup> Vue3

来源:1-1 课程介绍(导学 )

DanyLee

2022-01-26

输入正文

写回答

1回答

张轩

2022-01-27

Hi, as far as I know, there is no way to use spread operator in <setup> directly.

Alternatively, you can do:

1 use <script> without setup sugar sytanx.

setup() {
    return {
        ...useStuff()
    }
}

2  assign to one variable.

<script setup>
const stuff = useStuff()
</script>
<template>
{{stuff.abc}}
</template>


0
0

Vue3 + TS 仿知乎专栏企业级项目

带你完成前后端分离复杂项目,率先掌握 vue3 造轮子技能

3142 学习 · 2313 问题

查看课程