我不是很明白为什么这里不能直接赋值
发布于 7 年前 作者 icao 5770 次浏览 来自 问答

//就是e.detail.value不能赋值给其他变量

formSubmit: function (e) {

            console.log(‘form发生了submit事件,携带数据为:’, e.detail.value.name)

            values = e.detail.value

            this.setData({

            flag1:true,

            name1: e.detail.value.name,

            time_diff1: e.detail.value.time_diff,

            time1:goodtime(time_diff)

        })

    }

})

thirdScriptError

values is not defined;at pages/test/test page formSubmit function

ReferenceError: values is not defined

    at e.formSubmit (http://127.0.0.1:37389/appservice/pages/test/test.js:79:12)

    at e.<anonymous> (http://127.0.0.1:37389/appservice/__dev__/WAService.js:18:16884)

    at e.a (http://127.0.0.1:37389/appservice/__dev__/WAService.js:18:10983)

    at z (http://127.0.0.1:37389/appservice/__dev__/WAService.js:18:4899)

    at Function.<anonymous> (http://127.0.0.1:37389/appservice/__dev__/WAService.js:18:6520)

    at http://127.0.0.1:37389/appservice/__dev__/WAService.js:18:12486

    at http://127.0.0.1:37389/appservice/__dev__/WAService.js:6:27996

    at e.(anonymous function) (http://127.0.0.1:37389/appservice/__dev__/WAService.js:4:5071)

    at a (http://127.0.0.1:37389/appservice/appservice?t=1529377874528:1018:9472)

    at e.registerCallback (http://127.0.0.1:37389/appservice/appservice?t=1529377874528:1018:9659)

1 回复

你的 values  是哪来的?定义了吗?能不能访问到?

或者这样写:

var values = e.detail.value

回到顶部