vue实现数据的显示和隐藏

2020-04-03  本文已影响0人  Kemmy_m

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <title>head</title>

</head>

<script src="vue.min.js"></script>

<body>

<div id="app">

    <button @click="toggle">显示和隐藏数据</button><br>

    <span v-show="isshow">hello</span>

</div>

</body>

<script>

    new Vue({

        el:'#app',

        data:{

            return {

                    isshow:false

                };

        },

        methods:

        {

            toggle:function () {

                this.isshow=!this.isshow;//对它进行取反

            }

        }

    });

</script>

</html>

上一篇 下一篇

猜你喜欢

热点阅读