web前端全系列 教程
1839个小节阅读:2243.7k
目录
鸿蒙应用开发
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
发起 HTTPS 网络请求,从后端获取数据,显示在页面之上
通过wx.request
请求数据
xxxxxxxxxx
Page({
onLoad(options) {
wx.request({
url: 'https://iwenwiki.com/api/blueberrypai/getChengpinDetails.php',
success(res) {
console.log(res.data)
}
})
}
})
温馨提示
在小程序中使用网络相关的 API 时,需要注意下列问题,请开发者提前了解
- 每个微信小程序需要事先设置通讯域名,小程序只可以跟指定的域名进行网络通信(生产环境)
- 通过开发者工具配置:“不效验合法域名” (开发环境)
服务器域名请在 「小程序后台 - 开发 - 开发设置 - 服务器域名」 中进行配置
小程序开发者工具:详情 - 本地设置 - 勾选 “不效验合法域名” 选项
xxxxxxxxxx
<view>
<block wx:for="{{ chengpinDetails }}" wx:key="index">
<text>{{ item.title }}</text>
</block>
</view>
xxxxxxxxxx
Page({
data:{
chengpinDetails:[]
},
onLoad(options) {
var that = this;
wx.request({
url: 'https://iwenwiki.com/api/blueberrypai/getChengpinDetails.php',
success(res) {
that.adapterView(res)
}
})
},
adapterView(res){
this.setData({
chengpinDetails:res.data.chengpinDetails
})
}
})
实时效果反馈
1. 在微信小程序中,下列代码,划横线处应该填写的内容是:
xxxxxxxxxx
Page({
data:{
chengpinDetails:[]
},
onLoad(options) {
var that = _1_;
wx.request({
url: 'https://iwenwiki.com/api/blueberrypai/getChengpinDetails.php',
success(res) {
_2_.adapterView(res)
}
})
},
adapterView(res){
this.setData({
chengpinDetails:res.data.chengpinDetails
})
}
})
A this
this
B that
that
C that
this
D this
that
答案
1=>D