Rap 原分销系统代码Web
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
583B

  1. import store from '@/store'
  2. export default {
  3. inserted(el, binding) {
  4. const { value } = binding
  5. const roles = store.getters && store.getters.roles
  6. if (value && value instanceof Array) {
  7. if (value.length > 0) {
  8. const permissionRoles = value
  9. const hasPermission = roles.some(role => {
  10. return permissionRoles.includes(role)
  11. })
  12. if (!hasPermission) {
  13. el.parentNode && el.parentNode.removeChild(el)
  14. }
  15. }
  16. } else {
  17. throw new Error(`使用方式: v-permission="['admin','editor']"`)
  18. }
  19. }
  20. }