vuejs/docs-next-zh-cn

在script setup语法中如何实现{...toRef(state)}的写法呢

jzfai opened this issue · 1 comments

jzfai commented
{{stateDemo}}
<script> import { defineComponent,reactive,toRefs} from 'vue' // import validMixins from '@/mixins/validMixins.js' export default defineComponent({ setup(){ let state = reactive({stateDemo:1}) return{ ...toRefs(state) } } }) </script>

//script setup写法

{{stateDemo}}
<script setup> import { defineComponent,reactive,toRefs} from 'vue' // import validMixins from '@/mixins/validMixins.js' let state = reactive({stateDemo:1}) //无效 ...toRefs(state) //有效 let {stateDemo} = toRefs(state) </script>
veaba commented

抱歉,这里无法产生足够的讨论,本仓库 issue 仅做文档翻译用,感谢理解。