Vue常用指令v-else

可以用v-else指令为v-if或v-show添加一个“else块”。注意:v-else前一兄弟元素必须有 v-if 或 v-else-if。

doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title> v-else title>
    <script src="js/vue.js">script>
head>
<body>
<div id="app">
    <p v-if="height>170">Apollo的身高:{{ height }}CMp>
    <p v-else>Apollo的身高不符合要求!p>
div>

<script>
    // 创建Vue的实例
    let app = new Vue({
        el: '#app',
        data: {
            height: 168
        }
    })
script>
body>
html>

 

转载于:https://www.cnblogs.com/apollo1616/articles/10034202.html

你可能感兴趣的:(Vue常用指令v-else)