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-show指令</title>
    <script src="//static.gzj2001.com/vue/vue.js"></script>
</head>
<body>
    <div id="app">
        <div v-show="show" id="1">
            show=true
        </div>
        <div v-show="show2" id="2">
            show2=false
        </div>
        <button onclick="my()">读取</button>
    </div>
    <script>
        new Vue({
            el:"#app",
            data:{
                show:true,
                show2:false
            }
        })
        function my(){
            alert(document.getElementById("1").innerHTML);
            alert(document.getElementById("2").innerHTML);
        }
    </script>
</body>
</html>