vuejs / rfcs

RFCs for substantial changes / feature additions to Vue core
4.86k stars 548 forks source link

Cleaner Composition API #213

Closed johnsoncodehk closed 3 years ago

johnsoncodehk commented 3 years ago

When using Composition API, there is no need to write .value which will make the code much cleaner.

Transform Sample

For this code:

<template>
  <button @click="inc">{{ count }}</button>
  <p v-if="done">done!</p>
</template>

<script setup>
import { ref, computed } from 'vue'

export const count = ref(0)
export const done = computed(() => count.value > 100)
export const inc = () => count.value++
console.log(done.value)
</script>

When use no-ref, the <script> can replace to

<script setup noref>
export let count = 0 // @ref
export const done = count > 100 // @computed
export const inc = () => count++
console.log(done)
</script>

Rendered: 中文 | English

johnsoncodehk commented 3 years ago

Close because we are looking for a better way.

alamhubb commented 2 years ago

Hello, in my opinion, this proposal is very good. Why is it closed? Can you help me with this? Thank you very much.