收藏
回答

小程序表单提交必须提交两次才能成功?第一次提交是undefined 有那位朋友遇到过类似问题,

小程序表单提交必须提交两次才能成功?第一次提交是undefined 有那位朋友遇到过类似问题,求解决方法,代码如下:

Page({
  data: {
    postData: [],
  },
   formSubmit:function(e){
        console.log(e.detail.value)
        this.setData({postData:e.detail.value});
    },



    addfunction () {


        var self=this;


        var postParams = "is_ajax=1"
            +"&data[title]="  + self.data.postData.title
            +"&data[content]="  + self.data.postData.content
            +"&catid=11";
        wx.request({
            url: post_url,
            data: postParams,
            method'post',
            header: {
                'Content-Type''application/x-www-form-urlencoded',
            },
            successfunction (res{
                console.log(res.data);
                if (res.data.code) {
                    wx.showToast({
                        title: res.data.msg,
                        icon'success'
                    })
                }
                else {
                    wx.showModal({
                        showCancelfalse,
                        content: res.data.msg
                    })
                }
            }
        })
    },
回答关注问题邀请回答
收藏

3 个回答

登录 后发表内容