Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaner Composition API #213

Closed
wants to merge 13 commits into from
Closed

Cleaner Composition API #213

wants to merge 13 commits into from

Conversation

johnsoncodehk
Copy link
Member

@johnsoncodehk johnsoncodehk commented Sep 24, 2020

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
Copy link
Member Author

Close because we are looking for a better way.

@alamhubb
Copy link

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

@vuejs vuejs locked as resolved and limited conversation to collaborators Oct 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants