wx.request({
url: ‘https://chenzhoulife.com/API/post.php’, //仅为示例,并非真实的接口地址
data: {
title:‘1’
},
method:‘POST’,
header: {
‘Content-Type’: ‘application/json’
//‘Content-Type’: ‘application/x-www-from-urlencoded’
},
success: function(res) {
console.log(res.data)
}
})
},
formReset: function() {
console.log(‘form发生了reset事件’)
}
<?php
include ‘Mysql.class.php’;
$title = $_POST[‘title’];//$_POST[‘title’]数据接收不到
这样就可以了
Page({
formSubmit: function (e) {
console.log(‘form发生了submit事件,携带数据为:’, e.detail.value.title)
wx.request({
url: ‘https://chenzhoulife.com/API/post.php’, //仅为示例,并非真实的接口地址
data: {
title: e.detail.value.title,
contel: e.detail.value.contel
},
method: ‘POST’, // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
header: {
‘content-type’: ‘application/x-www-form-urlencoded; charset=UTF-8’
},
success: function (res) {
console.log(res.data)
}
})
},
formReset: function () {
console.log(‘form发生了reset事件’)
}
})