问答详情
源自:2-5 Vue中的计算属性和侦听器

下面显示的还是{{fullName}}

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>计算属性与侦听器</title>

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

</head>

<body>

<div id="root">

姓:<input v-model="firstName"/>

名:<input v-model="lastName"/>

<div>{{fullName}}</div>


</div>

<script>

new Vue({

el:"#root",

data:{

firstName:'',

lastName:''

}

computed:{

fullName:function(){

return this.firstName+this.lastName;

}

}

})

</script>

</body>

</html>


提问者:Never_Chan 2019-02-19 09:59

个回答

  • Never_Chan
    2019-02-19 10:00:33

    data{},没加逗号