博客
关于我
「小程序JAVA实战」小程序和后台api通信(28)
阅读量:342 次
发布时间:2019-03-04

本文共 611 字,大约阅读时间需要 2 分钟。

开发最重要的就是实操!

小程序和后台api通信

  • 小程序不能直接访问后台接口必须通过请求的方式
  • 通过内网穿透实现暴露到公网
  • ngrok ngrok.com

 

如何使用内网穿透

  • 登录ngrok网站
    >https://ngrok.com

  • 介绍
    >用户直接穿透防火墙,到云端做到互相的访问。

  • 如何使用
    >注册

下载ngrok

当前文件夹cmd执行命令

启动命令,显示online,说明内网穿透成功。

#ngrok http 指定端口ngrok http 8080

request

https://developers.weixin.qq.com/miniprogram/dev/api/network-request.html

wx.request({  url: 'test.php', //仅为示例,并非真实的接口地址  data: {     x: '' ,     y: ''  },  header: {    'content-type': 'application/json' // 默认值  },  success: function(res) {    console.log(res.data)  }})

标准的ajax请求,跟咱们之前的jquery基本是一样的,我就不详细说了,就是获取参数的传递。但是小程序内部也封装了很多东西,后面一起实战的时候一起来说。

PS:下一章节开始实战学习,从数据库的表开始设计。

转载地址:http://bmpe.baihongyu.com/

你可能感兴趣的文章
NN&DL4.1 Deep L-layer neural network简介
查看>>
NN&DL4.3 Getting your matrix dimensions right
查看>>
NN&DL4.7 Parameters vs Hyperparameters
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>
No module named 'pandads'
查看>>
No module named cv2
查看>>
No module named tensorboard.main在安装tensorboardX的时候遇到的问题
查看>>