image.png

代码

<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue.js中v-else指令</title>
    <script src="//static.gzj2001.com/vue/vue.js"></script>
</head>
<body>
    <div id="app">
        <div>
            {{random}}
        </div>
        <div v-if="random > 0.5">
            大于0.5
        </div>
        <div v-else>
            小于0.5
        </div>

    </div>
    <script>
        new Vue({
            el:"#app",
            data:{
                random:Math.random()
            }
        })
    </script>
</body>
</html>