收藏
回答

组件中abservers怎么使用哦?为何萌新总感觉没生效呢?文档上的预览点进去也没效果啊

{{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都不带改变一下的。求大佬指正一下哦


最后一次编辑于  09-27
回答关注问题邀请回答
收藏

1 个回答

问题标签