booleanProp
稳定性:
实验性 ⚠️ 实验性功能,风险自负把 <Comp checked /> 转换为 <Comp :checked="true" />。
把 <Comp !checked /> 转换为 <Comp :checked="false" />。
| Features | Supported |
|---|---|
| Vue 3 | ✅ |
| Nuxt 3 | ✅ |
| Vue 2 | ❌ |
| Volar Plugin | ✅ |
选项
ts
interface Options {
/**
* @default '!'
*/
negativePrefix?: string
}基本用法
vue
<script setup>
import Comp from './Comp.vue'
</script>
<template>
<Comp checked !enabled />
</template>vue
<script setup lang="ts">
// Comp.vue
defineProps<{
checked: true
enabled: false
}>()
</script>Volar 配置
jsonc
{
"vueCompilerOptions": {
"plugins": ["vue-macros/volar"],
"vueMacros": {
"booleanProp": true,
},
},
}
Kevin Deng
zhiyuanzmj
Leo