怎么我的小程序无法从数据库里取到数据的?

怎么我的小程序无法从数据库里取到数据的?,第1张

1.用到的知识点

wx.request 请求接口资源(微信小程序api中的发起请求部分)

swiper 实现轮播图的组件

wx:for 循环语句

微信小程序的基础知识

2.实现原理

首先,先看一下这个请求函数

var

wx.request({

url: '******', //这里填写你的接口路径

header: { //这里写你借口返回的数据是什么类型,这里就体现了微信小程序的强大,直接给你解析数据,再也不用去寻找各种方法去解析json,xml等数据了

'Content-Type': 'application/json'

},

data: {//这里写你要请求的参数

x: '' ,

y: ''

},

success: function(res) {

//这里就是请求成功后,进行一些函数 *** 作

console.log(res.data)

}

})1234567891011121314151612345678910111213141516

3.代码

分解图

首先上一段知乎接口数据的json格式中的开头

"date":"20161114",

"stories":[

{

"images":[

""

],

"type":0,

"id":8975316,

"ga_prefix":"111422",

"title":"小事 · 我和你们一样"

},

{

"images":[

""

],

"type":0,

"id":8977438,

"ga_prefix":"111421",

"title":"成长嘛,谁说就意味着一定要长大了?"

},12345678910111213141516171819201234567891011121314151617181920

index.js中

Page({

data: {

duration: 2000,

indicatorDots: true,

autoplay: true,

interval: 3000,

loading: false,

plain: false

},

onLoad: function () {

var that = this//不要漏了这句,很重要

wx.request({

url: '',

headers: {

'Content-Type': 'application/json'

},

success: function (res) {

//将获取到的json数据,存在名字叫zhihu的这个数组中

that.setData({

zhihu: res.data.stories,

//res代表success函数的事件对,data是固定的,stories是是上面json数据中stories

})

}

})

}

})12345678910111213141516171819202122232425262728291234567891011121314151617181920212223242526272829

index.wxml中

<swiper indicator-dots="{{indicatorDots}}"

autoplay="{{autoplay}}" class="banners" interval="{{interval}}" duration="{{duration}}">//这里边的属性不重要,看下边

{{item.title}}

1:仿豆瓣电影微信小程序

https://github.com/zce/weapp-demo

2:微信小程序移动端商城

https://github.com/liuxuanqiang/wechat-weapp-mall

3:Gank微信小程序

https://github.com/lypeer/wechat-weapp-gank

4:微信小程序高仿QQ应用

https://github.com/xiehui999/SmallAppForQQ

5:微信中的知乎

https://github.com/RebeccaHanjw/weapp-wechat-zhihu

6:实现一个移动端小商城

https://github.com/skyvow/m-mall

7:微信小程序demo

https://github.com/web-Marker/wechat-Development

8: 跑步微信小程序Demo

https://github.com/alanwangmodify/weChatApp-Run

9:简单的v2ex微信小程序

https://github.com/jectychen/wechat-v2ex

10:腾讯云微信小程序

https://github.com/tencentyun/weapp-client-demo

11:微信小程序-微票

https://github.com/wangmingjob/weapp-weipiao

12:微信小程序demo 仿手机淘宝

https://github.com/ChangQing666/wechat-weapp-taobao

13:一个为微信小程序开发准备的基础骨架

https://github.com/zce/weapp-boilerplate

14:巴爷微信商城的简单版本

https://github.com/bayetech/wechat_mall_applet

15:微信小程序 - 电影推荐

https://github.com/yesifeng/wechat-weapp-movie

16:微信小程序-知乎日报

https://github.com/myronliu347/wechat-app-zhihudaily

17:微信小程序: 音乐播放器

https://github.com/eyasliu/wechat-app-music

18:使用微信小程序实现分答这款APP的基础功能

https://github.com/davedavehong/fenda-mock

19:微信小程序开发demo-地图定位

https://github.com/giscafer/wechat-weapp-mapdemo

:20:微信小程序 - 豆瓣电影

https://github.com/hingsir/weapp-douban-film

21:wepy仿微信聊天界面

https://github.com/wepyjs/wepy-wechat-demo

22:仿 「ONE · 一个」 的微信小程序

https://github.com/ahonn/weapp-one

23:微信小程序集成Redux实现的Todo list

https://github.com/charleyw/wechat-weapp-redux-todos

24: 基于Zhihu Live数据的微信小程序

https://github.com/dongweiming/weapp-zhihulive

25:微信小程序之小熊の日记

https://github.com/harveyqing/BearDiary

26:仿网易云音乐APP的微信小程序

https://github.com/sqaiyan/netmusic-app

27:微信小程序的Flex布局demo

https://github.com/icindy/wxflex

28:番茄时钟微信小程序版

https://github.com/kraaas/timer

29:Wafer 服务端 Demo

https://github.com/tencentyun/weapp-node-server-demo

30:微信小程序版聊天室

https://github.com/ericzyh/wechat-chat

31:微信小程序版简易计算器,适合入门练手

https://github.com/dunizb/wxapp-sCalc

32:微信小程序示例一笔到底

https://github.com/CFETeam/weapp-demo-session

33:基于面包旅行 API 制作的微信小程序示例

https://github.com/romoo/weapp-demo-breadtrip

34:新闻阅读器

https://github.com/vace/wechatapp-news-reader

35:一个简单的微信小程序购物车DEMO

https://github.com/SeptemberMaples/wechat-weapp-demo

36:微信小程序-公众号热门文章信息流

https://github.com/hijiangtao/weapp-newsapp

37:通过Node.js实现的妹子照片爬虫微信小程序

https://github.com/litt1e-p/weapp-girls

38:从FlexLayout布局开始学习微信小程序

https://github.com/hardog/wechat-app-flexlayout

39:HiApp 微信小程序版

https://github.com/BelinChung/wxapp-hiapp

40:微信小程序的简单尝试

https://github.com/zhengxiaowai/weapp-github

41:集美大学图书馆的便捷工具

https://github.com/ToadWoo/bookbox-wxapp

42:微信小程序版妹纸图

https://github.com/brucevanfdm/WeChatMeiZhi

43:V2ex 微信小程序版

https://github.com/bestony/weapp-V2ex

44:微信小程序仿百思不得姐

https://github.com/SureZhangHW/WXBaiSi

45:微信小程序音乐播放器应用

https://github.com/xingbofeng/wx-audio

46:医药网原生APP的微信小程序DEMO

https://github.com/jiabinxu/yiyaowang-wx

47:微信小程序跟读

https://github.com/gxmzjxk/wxreading

48:微信小程序瀑布流布局模式

https://github.com/icindy/WxMasonry

49:微信小程序HotApp云笔记

https://github.com/hotapp888/hotapp-notepad

50:小程序模仿——网易云音乐

https://github.com/MengZhaoFly/wechatApp-netease_cloudmusic

51:微信小程序商城demo

https://github.com/lin-xin/wxapp-mall

52:微信小程序版的扫雷

https://github.com/jsongo/wx-mime

53:专注管理时间的微信小程序

https://github.com/SeaHub/PigRaising

54:微信小程序版干货集中营

https://github.com/iwgang/GankCamp-WechatAPP

55:英雄联盟(LOL)战绩查询

https://github.com/xiaowenxia/weapp-lolgame

56:微信小程序首字母排序选择表

https://github.com/icindy/wxSortPickerView

57:微信小程序版豆瓣电影

https://github.com/David-Guo/weapp-douban-movie

58:简单的实现了1024的游戏规则

https://github.com/RedLove/WexinApp_1024

59:微信小程序试玩

https://github.com/uniquexiaobai/wechat-app-githubfeed

60:微信小程序逗乐

https://github.com/mkxiansheng/doule

61:一步步开发微信小程序

https://github.com/Gavin-YYC/wxApp

62:一个 meteor 的 React todo list 例子

https://github.com/leijing7/wx-mina-meteor

63:微信小程序健康菜谱

https://github.com/bestTao/caipu_weixin

64: jspapa微信小程序版本

https://github.com/biggerV/jspapa-wx

65:微信小程序版的CNodeJs中文社区

https://github.com/Shaman05/CNodeJs-WXAPP

66:LeanCloud 的微信小程序用户登陆Demo

https://github.com/bestony/weapp-LeanCloud

67: 微笑话微信小程序

https://github.com/zszdevelop/wejoke

68:微信小程序开发的App

https://github.com/chongbenben/liwushuoapp

69:体育新闻微信小程序

https://github.com/havenxie/weapp-sportsnews

70:基于Labrador和mobx构建的小程序开发demo

https://github.com/spacedragon/labrador_mobx_example

腾讯云微信小程序搭建的 *** 作步骤:

第一步:准备账号

注册微信小程序 >(你得有个微信公众号)

注册腾讯云帐号 >(你还得有个腾讯云账号,QQ登录也可以的,但要实名认证哟)

第二步:关联帐号

关联微信小程序与腾讯云帐号,账号关联才能实现一站式解决。如何绑定微信小程序账号到腾讯云?进入腾讯云账号中心,点击微信公众平台登录后面的【关联】按钮即可关联:如下图

05

第三步:开通环境

开通开发环境和开通生产环境。

为了方便开发调试,防止影响到线上服务,腾讯云提供开发和生产两套环境,两套环境的代码部署、运行、与数据库是完全隔离的。

两套环境拥有以下特点:

开发环境————

免费使用

自动分配测试用二级域名:xxxxxxx.qcloud.la

自动部署免费 HTTPS

仅可用于线上调试,不可发布

代码部署、运行和数据库与生产环境完全分开

与微信开发工具打通,可一键部署、调试、重启和恢复代码

生产环境—————

付费使用

用户需购买或使用已有的腾讯云域名

自动部署免费 HTTPS

用于线上发布,不可调试

使用微信开发工具上传代码,在腾讯云控制台 *** 作部署,上传和发布分离,降低误 *** 作风险

第四步:搭建小程序

PHP 方案开通指引:(1)通过微信公众平台授权登录腾讯云(2)安装开发工具(3)初始化 Demo

自行部署适用于想将腾讯云 Wafer SDK 和 Demo 部署在自己的服务器上以获得更高的灵活性和 *** 纵权限的用户。部署过程需要从零开始搭建线上环境,需要有一定的 Linux、PHP 基础。如果您符合以上需求和条件,可以自行部署。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/11269414.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-14
下一篇2023-05-14

发表评论

登录后才能评论

评论列表(0条)

    保存