Skip to content

Variable: Can ​

ts
const Can: DefineComponent<ExtractPropTypes<{
  allOf: {
     default: undefined;
     type: PropType<NameList>;
  };
  anyOf: {
     default: undefined;
     type: PropType<NameList>;
  };
  not: {
     default: boolean;
     type: BooleanConstructor;
  };
  permission: {
     default: undefined;
     type: PropType<NameList>;
  };
}>, () => 
  | VNode<RendererNode, RendererElement, {
[key: string]: any;
}>[]
  | null, {
}, {
}, {
}, ComponentOptionsMixin, ComponentOptionsMixin, {
}, string, PublicProps, ToResolvedProps<ExtractPropTypes<{
  allOf: {
     default: undefined;
     type: PropType<NameList>;
  };
  anyOf: {
     default: undefined;
     type: PropType<NameList>;
  };
  not: {
     default: boolean;
     type: BooleanConstructor;
  };
  permission: {
     default: undefined;
     type: PropType<NameList>;
  };
}>, {
}>, {
  allOf: NameList;
  anyOf: NameList;
  not: boolean;
  permission: NameList;
}, Slots, {
}, {
}, string, ComponentProvideOptions, true, {
}, any>;

Defined in: packages/vue/src/components.ts:18

Renders the default slot when the user has the permission(s), otherwise the #fallback slot.

vue
<Can permission="edit articles">...</Can>
<Can :any-of="['edit articles', 'delete articles']">...<template #fallback>No access</template></Can>
<Can :all-of="['a', 'b']">...</Can>

Released under the MIT License. Inspired by spatie/laravel-permission.