v-if的使用方式

时间:2019-12-31
本文章向大家介绍v-if的使用方式,主要包括v-if的使用方式使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

一、语法

其中<span></span>可以换成<div></div>,

<div></div>的可以换成<templete></templete>都没关系

<el-table-column label="管理员" prop="isAdmin">
            <div slot-scope="scope">
              <span v-if="scope.row.isAdmin===1">管理员</span>
              <span v-else-if="scope.row.isAdmin===0">普通成员</span>
            </div>
</el-table-column>

二、结构

<div slot-scope="scope">
              <span v-if="scope.row.isAdmin===1">管理员</span>
              <span v-else-if="scope.row.isAdmin===0">普通成员</span>
</div>

是个两层结构,若是加入v-else仍然是两层结构

<div id="app">
    <div v-if="type === 'A'">
      A
    </div>
    <div v-else-if="type === 'B'">
      B
    </div>
    <div v-else-if="type === 'C'">
      C
    </div>
    <div v-else>
      Not A/B/C
    </div>
</div>

原文地址:https://www.cnblogs.com/yanl55555/p/12123174.html