跳到正文

booleanProp NPM Version ​

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

把 <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 配置 ​

tsconfig.json
jsonc
{
  "vueCompilerOptions": {
    "plugins": ["vue-macros/volar"],
    "vueMacros": {
      "booleanProp": true,
    },
  },
}

贡献者

页面历史

用 ❤️ 发电