组件中abservers怎么使用哦?为何萌新总感觉没生效呢?文档上的预览点进去也没效果啊
发布于 6 年前 作者 ajia 9109 次浏览 来自 官方Issues

{{sum}}

<input bindinput="numbera" value="{{numberA}}"></input>

<input bindinput="numberb" value="{{numberB}}"></input>

Component({

    properties: {

        testData1: Number,

        testData2: String,

    },

    data: {

        sum: 10

    },

    methods: {

        onLoad: function (options) {

            this.setData({

                numberA: Math.random() * 10,

                numberB: Math.random()

                })

        },

            numbera(e){

                this.setData({

                numberA: e.detail.value

            })

        },

        numberb(e) {

            this.setData({

                numberB: e.detail.value

            })

        }

    },

    abservers: {

        'numberA, numberB': function (numberA, numberB) {

            this.setData({

                sum: numberA + numberB

            })

        }

    }

})


这个num都不带改变一下的。求大佬指正一下哦

回到顶部