<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="vue.js"></script> </head> <body> <div id="app"> <button @click="handleIf">v-if</button> <button @click="handleShow">v-show</button> <button @click="handleShowB">v-if-b</button><button @click="handleShowC">v-if-c</button> <div v-if="ifShow" style="width: 100px;height: 100px;background-color: red" >v-if</div> <div v-show="show" style="width: 100px;height: 100px;background-color: black" >v-show</div> <div v-if="value=='a'" style="width: 100px;height: 100px;background-color: green" >v-if-a</div> <div v-else-if="value=='b'" style="width: 100px;height: 100px;background-color: red" >v-if-b</div> <div v-else style="width: 100px;height: 100px;background-color: orange" >v-if -c</div> </div> <script> var app=new Vue({ el:"#app", data:{ content:'hello vue', ifShow:false, show:false, value:'a' }, methods:{ handleIf:function () { this.ifShow=!this.ifShow }, handleShow:function () { this.show=!this.show }, handleShowB:function () { this.value='b' }, handleShowC:function () { this.value='c' } } }) </script> </body> </html>