vue-macros / vue-macros

Explore and extend more macros and syntax sugar to Vue.

Home Page:https://vue-macros.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add $defineProp

zhiyuanzmj opened this issue · comments

Clear and concise description of the problem

Add reactivity transform support to defineProp.

Suggested solution

<script setup lang="ts">
// Kevin's Edition
const foo = defineProp<string>()
const bar = $defineProp('bar', { default: 'bar', required: true })
const baz = $(defineProp('baz', { default: 'baz' }))
console.log(foo.value, bar, baz)

// Johnson's Edition
const foo = defineProp<string>()
const bar = $defineProp(() => 'bar', true)
const baz = $(defineProp('baz'))
console.log(foo.value, bar, baz)
</script>

Alternative

No response

Additional context

No response

Validations