vuejs / rfcs

RFCs for substantial changes / feature additions to Vue core
4.85k stars 551 forks source link

If I use "<script setup>", how can I "export" the "toRefs(state)"? #250

Closed chen-jiajin closed 3 years ago

chen-jiajin commented 3 years ago
<template>
  <!-- I don't want to use 'state.value', so I use 'toRefs' -->
  <div>{{label}}: {{value}}</div>
</template>

<script>
import { reactive, ref, toRefs } from 'vue'
export default {
  setup(){
    const label = ref('hello')
    const state = reactive({
       value: 0
    }) // If the object has more attribute values
    return {
      ...toRefs(state),
      label
    }
  }
}
</script>

If I use " Githubissues.

  • Githubissues is a development platform for aggregating issues.