微信小程序和ASP.NET WebAPI本地的链接
------------恢复内容开始------------
在asp.net webapi写一个get请求的接口
在微信小程序 .wxml文件中添加个按钮并给他点击事件
<button bindtap="btnBtn" >点击</button>
在.js文件中添加一个按钮点击方法,url地址就填写asp.net webapi运行时浏览器上地址栏里的地址
btnBtn:function(){
wx.request({
url:'http://localhost:52384/api/values/WX?id=1&name=zhangsan',
method:'get' ,
header:
{
'Content-Type':'alication/json'
},
success:function(res)
{
console.log(res.data)
}
})
},
运行出错时,点击微信小程序上的【设置】、【项目设置】、把【不检验合法域名、web-view(业务域名)、TLS版本以及HTTPS证书】打上勾就可以了
------------恢复内容结束------------

浙公网安备 33010602011771号