Skip to content

booleanProp

稳定性: 实验性 ⚠️ 实验性功能,风险自负

<Comp checked /> 转换为 <Comp :checked="true" />

<Comp !checked /> 转换为 <Comp :checked="false" />

FeaturesSupported
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
// tsconfig.json
{
  "vueCompilerOptions": {
    "target": 3,
    "plugins": [
      "@vue-macros/volar/boolean-prop",
      // ...更多功能
    ],
  },
}

贡献者

The avatar of contributor named as renovate[bot] renovate[bot]

页面历史