Vue中的 v-if 和 v-else-if 多层判断的用法

第一种用法:v-if —— v-else-if —— v-else

<el-table-column prop="versionStatus" label="状态">
    <template slot-scope="scope">					
        <p v-if="scope.row.versionStatus=='1'">在用</p>
        <p v-else-if="scope.row.versionStatus=='2'">过期</p>
        <p v-else-if="scope.row.versionStatus=='3'">作废</p>
        <p v-else-if="scope.row.versionStatus=='4'">停用</p>
        <p v-else>未知</p>					
    </template>
</el-table-column>

第二种用法:v-if —— v-else

<el-table-column prop="versionStatus" label="状态">
    <template slot-scope="scope">					
        <p v-if="scope.row.versionStatus=='1'">在用</p>
        <p v-if="scope.row.versionStatus=='2'">过期</p>
        <p v-if="scope.row.versionStatus=='3'">作废</p>
        <p v-if="scope.row.versionStatus=='4'">停用</p>
        <p v-else>未知</p>					
    </template>
</el-table-column>
发布了144 篇原创文章 · 获赞 25 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/AdminGuan/article/details/103570750