v-permission
Function Introduction
Rapid realization of authentication
Example
Usage
javascript
<script setup lang="ts">
import { ref } from 'vue'
// Ordinary user rights, obtained from the background
const normal = ref(['update','query']);
// Administrator permissions, obtained from the background
const admin = ref(['add', 'del', 'update', 'query']);
const adminString = ref('add;del;update;query'); // String format
</script>
<template>
<button v-permission="normal">Special function 1</button>
<button v-permission="admin">Special function 2</button>
<button v-permission="adminString">Special function 3</button>
</template>
Rule
v-permission="permissionList
"
permissionList type: Array <string>
or string
(separated by semicolons).
Permission list: ['add',' del']
, one of which is displayed, otherwise the element is hidden
TIP
Please do not mix with v-if!