当前位置 : 主页 > 网页制作 > HTTP/TCP >

vue中计算属性和侦听属性

来源:互联网 收集:自由互联 发布时间:2021-06-16
!DOCTYPE htmlhtml lang="en"head meta charset="UTF-8" meta name="viewport" content="width=device-width, initial-scale=1.0" meta http-equiv="X-UA-Compatible" content="ie=edge" titlevue 入门/title script src="/uploads/allimg/210616/1Q13W614-
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>vue 入门</title>
    <script src="http://img.558idc.com/uploadfile/allimg/210616/1Q13W614-0.jpg"></script>

</head>
<body>

    <div id="app">
        姓 <input type="text" v-model=‘firstname‘>

        名 <input type="text" v-model="lastname">

        <span>{{ fullName }}</span>
        <span>{{ count }} </span>
    </div>
    <script>
        new Vue({
            el:"#app",
            data:{
                firstname:‘‘,
                lastname:‘‘,
                count:0
            },
            computed:{
                fullName (){
                    return   this.firstname + this.lastname
                }
            },
            watch:{
                fullName:function(){
                    this.count++
                }
            }
           
        })
    
    </script>
</body>
</html>
网友评论