掘金小册《微信小程序开发入门:从 0 到 1 实现天气小程序》源码,欢迎购买小册支持作者(全网价格9.9)。
内容由三部分组成:
- 小程序开发基础知识:这部分主要介绍微信小程序、小程序云开发基础知识,最后介绍了小程序的运行机制
- 实战开发「新鲜天气」小程序:从脚手架搭建开始,将「新鲜天气」的天气预报和心情签到页面从布局到功能实现进行全面讲解,涉及小程序研发中绝大部分 API 和重要流程的梳理实现
- 优化到上线:从多个方面介绍小程序优化的知识点,并且完成小程序的上线
新鲜天气:使用小程序·云开发的小程序
Home Page: https://juejin.im/book/5b70f101e51d456669381803/
掘金小册《微信小程序开发入门:从 0 到 1 实现天气小程序》源码,欢迎购买小册支持作者(全网价格9.9)。
内容由三部分组成:
根据经纬度获取天气时,一直500错误,获取空气质量正常。测试和风天气免费接口没有问题
按书籍中做了各种配置后,本地跑起来后报错,加载失败,请稍后再试
经排查,需要进入一下几步操作
client/project.config.json
文件中需要添加 appid
, 否则会报appid missing
的错误server/cloud-functions/he-weather/index.js
文件需要修改为如下。key替换为自己的密钥。const API_URL = 'https://free-api.heweather.net/s6/weather'
const request = require('request')
/*<jdists import="../../inline/utils.js" />*/
/*<remove>*/
const $ = require('../../inline/utils')
/*</remove>*/
exports.main = async (event) => {
const {lat,lon} = event
let location = `${lat},${lon}`
let params = {
location,
key: '-----------------' //替换为密钥
// t: Math.floor(Date.now() / 1e3),
// unit: 'm'
}
// 生成签名
// params.sign = $.generateSignature(params)
let query = []
for (let i in params) {
query.push(`${i}=${encodeURIComponent(params[i])}`)
}
let url = API_URL + '?' + query.join('&')
console.log(url)
return new Promise((resolve, reject) => {
request.get(url, (error, response, body) => {
console.log(body)
if (error || response.statusCode !== 200) {
reject(error)
} else {
try {
let rs = $.handlerData(JSON.parse(body))
console.log(rs)
resolve(rs)
} catch (e) {
reject(e)
}
}
})
})
}
大佬,这个要怎么解决?
问题:首页的地址定位接口报错,然后就显示默认地址【北京市海淀区西二旗北路】。
解决方案:在微信公众平台开发-开发设置-服务器域名
中添加服务器域名
wx.request
方法受服务器域名配置限制。
文档:https://developers.weixin.qq.com/miniprogram/dev/framework/ability/network.html
这一点希望可以写到文档中~~
Originally posted by @sqh17 in #1 (comment)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.