为了账号安全,请及时绑定邮箱和手机立即绑定
关注
qq_慕码人8528369

数据改变后触发不了监听器是怎么回事

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>监听器</title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
<div id="root">
</div>
<script>
    new Vue({
        el: "#root",
        template: `<div >
                     <input v-model="firstName">
                     <input v-model="lastName">
                     <div>{{fullName}}</div>
                     <div>{{number}}</div>
                   </div>`,
        data: {
            firstName: "",
            lastName: '',
            number: 0,
        },
        computed: {
            fullName: function () {
                return this.firstName + this.lastName
            }
        },
        match: {
            fullName: function () {
                console.log('数据发生了改变')
                this.number++
            }
        }
    })
</script>
</body>
</html>

https://img4.sycdn.imooc.com/5d626ae9000181a119140360.jpg

2019-08-25 源自:vue2.5入门 2-5 269 浏览 1 回答

最佳回答

2019-08-26

qq_慕码人8528369 (提问者)

天哪,居然犯这种错误,谢谢哈
#1 2019-08-27

DCFY

哪里错误了需要怎么该呢?不懂
#2 2020-03-18

慕码人0226809

match watch
#3 2020-04-15

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信