VUE 学习 之 {{}}

VUE里面的{{}}符合可以书写JS表达式,但是不可以书写语句。例子:


<!DOCTYPE html>
<html>
<head>

    <title>VUE hello world</title>

    <script src="https://unpkg.com/vue/dist/vue.js"></script>

    <style>

        #simple{
            margin-left: 100px;
            margin-top: 100px;
            width: 100px;
            height: 100px;

            background-color: #00a9a7;
        }

    </style>

</head>


<body>

<div id="simple">
    <p>{{name}}</p>
    <p>{{isShow ? "show" : "hide"}}</p>
    <p>{{number1 + number2}}</p>
</div>


<script>
var simpleID = new Vue({
    el:"#simple",
    data:{
        name : "hello world",
        isShow : false,
        number1: 10,
        number2: 20
    }
})

    simpleID.number2 = 30;
</script>

</body>
</html>

猜你喜欢

转载自blog.csdn.net/liubangbo/article/details/81009843
今日推荐