06-Vueの条件レンダリング【v-else-i f】

4990 ワード

DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>    title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js">script>
head>
<body>
    <div id="app">
        <div v-if='flag==="a"' >   1    div>
        <div v-else-if='flag==="b"'>   2    div>
        <div v-else>   3    div>
        <hr>
    div>
    <script>
        var app  =new Vue({
            el:'#app',
            template:'',
            data:{
                flag:'a',
            },
            methods: {
                
            },
        })
    script>
body>
html>
 
転載先:https://www.cnblogs.com/suni1024/p/11540143.html