Skip to content

自定义指令

框架提供了许多常用的自定义指令可以直接使用。

v-authority

如果当前登录用户拥有指令传入的权限标识,则渲染元素。

html
<button v-authority="'superAdmin'">查询</button>
<!-- 支持传入多个权限标识 -->
<button v-authority="['admin', 'superAdmin']">查询</button>

提示

使用前需要注入权限校验业务。

v-remove

用于移除某一个dom元素,同时保留该dom元素所有的子元素。

html
<div class="container" v-remove>
  <div class="content">内容1</div>
  <div class="content">内容2</div>
  <div class="content">内容3</div>
</div>

最终将渲染:

html
<div class="content">内容1</div>
<div class="content">内容2</div>
<div class="content">内容3</div>