onLoad: function (options) {
var that = this
this.title = options.title
wx.request({
url: '' + options.id,
headers: {
'Content-Type': 'application/json'
},
success: function (res) {
that.setData({
list: res.data.stories
})
console.log(res.data)
}
})
}
option的介绍呢?另外,我服务器没有配置,如何模拟数据返回?我先在客户端模拟服务器数据返回,如何做?
类似这个形式?
module.exports = {
"meta": {
"code": 200
},
"data": {
"topwords": [{
"word": "\u6df1\u6539\u7ec41000\u5929",
"timestamp": "1474378841"
},
{
"word": "\u8d85\u7ea7\u5929\u773c",
"timestamp": "1469980137"
},
{
"word": "\u5973\u513f\u5077\u5356\u623f\u4ea7",
"timestamp": "1474342113"
},
{
"word": "\u52a0\u5185\u7279\u9000\u5f79",
"timestamp": "1473320725"
},
{
"word": "\u88ab\u62d027\u5e74\u8ba4\u51fa",
"timestamp": "1474342280"
},
{
"word": "\u6c64\u663e\u7956\u56db\u767e\u5468\u5e74",
"timestamp": "1473790804"
},
{
"word": "\u671d\u9c9c\u822a\u7a7a\u5c55",
"timestamp": "1467127511"
},
{
"word": "Note2\u8d77\u706b",
"timestamp": "1474601356"
},
{
"word": "\u5bb6\u6709\u513f\u5973\u91cd\u805a",
"timestamp": "1465786724"
},
{
"word": "\u83f2\u603b\u7edf\u5c06\u8bbf\u534e",
"timestamp": "1470233504"
}],
"topnews": [{
"img": "http:\/\/img02.sogoucdn.com\/app\/a\/100520091\/20160925111957",
"title": "\u5982\u679c\u6ca1\u6709\u5b83\uff0cVR\u6ce8\u5b9a\u662f\u573a\u201c\u95f9\u5267\u201d",
"summary": "\u884c\u4e1a\u7f3a\u5c11\u4f18\u8d28\u6807\u7684\uff0c\u5173\u952e\u6027\u6280\u672f\u8282\u70b9\u8fdc\u672a\u7a81\u7834\uff0cVR\u5982\u540c\u4e00\u4e2a\u7259\u7259\u5b66\u8bed\u7684\u5a74\u513f\uff0c\u5c1a\u5728\u8941\u8913\u4e4b\u4e2d\uff0c\u8fdc\u672a\u6210\u719f\u3002\u8fd9\u91cc\u7684\u201c\u5173\u952e\u6027\u6280\u672f\u8282\u70b9\u201d\u5176\u4e2d\u4e4b\u4e00\uff0c\u5c31\u662f\u7a7a\u95f4\u97f3\u9891\u6280\u672f\u3002\u5728\u4eca\u5929\uff0c\u4eba\u4eec\u66f4\u613f\u610f\u53eb\u5b833D\u97f3\u9891\u3002",
"account": "36\u6c2a",
"timestamp": "1474773478",
"date": "11:17",
"link": "http:\/\/mp.weixin.qq.com\/s?__biz=MjAzNzMzNTkyMQ==&mid=2653752531&idx=1&sn=53a0a4bc0d85a0b09632397be9d57043&chksm=4a891ccd7dfe95db985a25a6a7b201b31f2626ecc7bb9b9fa42e308ffe1f4a590b27d57ceeae&scene=0#rd",
"srclink": "http:\/\/mp.weixin.qq.com\/s?__biz=MjAzNzMzNTkyMQ==&mid=2653752531&idx=1&sn=53a0a4bc0d85a0b09632397be9d57043&chksm=4a891ccd7dfe95db985a25a6a7b201b31f2626ecc7bb9b9fa42e308ffe1f4a590b27d57ceeae&scene=0#rd",
"openid": "oIWsFt-NQJJTI1l_HJBI-iEy3qbg"
},
{
"img": "http:\/\/img03.sogoucdn.com\/app\/a\/100520091\/20160925112244",
"title": "\u4e2d\u56fd\u53c8\u4e00\u9879\u4e16\u754c\u4e4b\u6700\u5de5\u7a0b\u7ae3\u5de5\uff01",
"summary": "\u7ecf\u8fc722\u5e74\u9009\u5740\u3001\u8bbe\u8ba1\u3001\u65bd\u5de5\uff0c\u4eca\u5929\uff0c\u5168\u7403\u6700\u5927500\u7c73\u53e3\u5f84\u7403\u9762\u5c04\u7535\u671b\u8fdc\u955cFAST\u7ae3\u5de5\uff0c\u5e76\u8fdb\u5165\u8c03\u8bd5\u3001 \u8bd5\u89c2\u6d4b\u9636\u6bb5\u3002\u4eca\u540e\uff0c\u5b83\u5c06\u5e26\u7740\u5927\u5bb6\u4e00\u8d77\u89c1\u8bc1\u79d1\u5b66\u5947\u8ff9\uff01",
"account": "\u592e\u89c6\u65b0\u95fb",
"timestamp": "1474773695",
"date": "11:21",
"link": "http:\/\/mp.weixin.qq.com\/s?__biz=MTI0MDU3NDYwMQ==&mid=2656542911&idx=2&sn=eb7d1ad8ae70f44eba50f88b92bcab76&scene=0#rd",
"srclink": "http:\/\/mp.weixin.qq.com\/s?__biz=MTI0MDU3NDYwMQ==&mid=2656542911&idx=2&sn=eb7d1ad8ae70f44eba50f88b92bcab76&scene=0#rd",
"openid": "oIWsFt_IC706OXjJP2sn_T5MxVfs"
},
{
"img": "http:\/\/img01.sogoucdn.com\/app\/a\/100520091\/20160925112525",
"title": "\u5e0c\u62c9\u91ccVS\u7279\u6717\u666e\u9996\u573a\u7535\u89c6\u8fa9\u8bba\uff0c\u5468\u4e00\u89c1\uff01",
"summary": "\u518d\u8fc7\u4e00\u4e2a\u591a\u6708\uff0c11\u67088\u65e5\uff0c\u5c31\u662f\u4eca\u5e74\u7684\u7f8e\u56fd\u603b\u7edf\u9009\u4e3e\u65e5\uff0c\u773c\u4e0b\u5927\u9009\u8fdb\u5165\u4e86\u6700\u540e\u51b2\u523a\u9636\u6bb5\u3002",
"account": "\u592e\u89c6\u65b0\u95fb",
"timestamp": "1474773845",
"date": "11:24",
"link": "http:\/\/mp.weixin.qq.com\/s?__biz=MTI0MDU3NDYwMQ==&mid=2656542911&idx=3&sn=115c571dcda8326535cb0f6fa6e7071c&scene=0#rd",
"srclink": "http:\/\/mp.weixin.qq.com\/s?__biz=MTI0MDU3NDYwMQ==&mid=2656542911&idx=3&sn=115c571dcda8326535cb0f6fa6e7071c&scene=0#rd",
"openid": "oIWsFt_IC706OXjJP2sn_T5MxVfs"
},
{
"img": "http:\/\/img03.sogoucdn.com\/app\/a\/100520091\/20160925113011",
"title": "\u8d8a\u6765\u8d8a\u591a\u7684\u7a7a\u5de2\u9752\u5e74\uff0c\u8981\u600e\u6837\u4e00\u4e2a\u4eba\u751f\u6d3b\uff1f",
"summary": "\u72ec\u5c45\u4eba\u53e3\u7684\u589e\u591a\uff0c\u5df2\u7ecf\u6210\u4e3a\u773c\u4e0b\u4e2d\u56fd\u65e0\u6cd5\u5ffd\u89c6\u7684\u793e\u4f1a\u73b0\u8c61\u3002\u4eba\u4eec\u8fd8\u80fd\u548c\u4ece\u524d\u4e00\u6837\u5c06\u5176\u89c6\u4e3a\u6027\u683c\u5b64\u50fb\u3001\u81ea\u7518\u5815\u843d\u5417?\u201c\u7a7a\u5de2\u201d\u4e8c\u5b57\u662f\u5426\u6709\u8fc7\u5ea6\u6e32\u67d3\u67d0\u79cd\u60b2\u60c5\u8272\u5f69\u7684\u5acc\u7591?\u4eca\u5929\uff0c\u5c0f\u7f16\u5c31\u548c\u5927\u5bb6\u804a\u804a\u4e00\u4e2a\u4eba\u7684\u751f\u6d3b\u3002",
"account": "\u65b0\u4eac\u62a5",
"timestamp": "1474774120",
"date": "11:28",
"link": "http:\/\/mp.weixin.qq.com\/s?__biz=MjM5MjMxMTY0MA==&mid=2652588940&idx=4&sn=c2a0836943c288d5dce6098462fa1744&chksm=bd47dbbb8a3052ad64fd77d6eb102fa31998b7d18ac52a6395fb3bff09adbb0935ba7e4d082b&scene=0#rd",
"srclink": "http:\/\/mp.weixin.qq.com\/s?__biz=MjM5MjMxMTY0MA==&mid=2652588940&idx=4&sn=c2a0836943c288d5dce6098462fa1744&chksm=bd47dbbb8a3052ad64fd77d6eb102fa31998b7d18ac52a6395fb3bff09adbb0935ba7e4d082b&scene=0#rd",
"openid": "oIWsFt2RqUUeklhTavcPZO8PMvSw"
},
{
"img": "http:\/\/img04.sogoucdn.com\/app\/a\/100520091\/20160925113321",
"title": "\u4e09\u672c\u8de8\u8d8a\u65f6\u7a7a\u7684\u4e66\uff0c\u88ab\u521b\u4f5c\u51fa\u6765\u5168\u9760\u5de7\u5408",
"summary": "\u5bf9\u4e8e\u4f5c\u8005\u6765\u8bf4\uff0c\u5728\u521b\u4f5c\u74f6\u9888\u4e4b\u65f6\uff0c\u6ca1\u6709\u4ec0\u4e48\u6bd4\u201c\u65e0\u5de7\u4e0d\u6210\u4e66\u201d\u5e26\u6765\u7684\u5feb\u611f\u66f4\u5f3a\u70c8\uff0c\u90a3\u6837\u7684\u611f\u89c9\u5c31\u50cf\u662f\u751f\u6d3b\u5728\u4e0a\u5e1d\u64cd\u7eb5\u7684\u6709\u5e8f\u5b87\u5b99\u4e2d\uff0c\u4ed6\u5728\u80cc\u540e\u76d1\u7763\uff0c\u8fd8\u6254\u7ed9\u4f60\u4e00\u4e9b\u542b\u6df7\u7684\u7ebf\u7d22\uff0c\u5e2e\u4f60\u611f\u53d7\u4e07\u7269\u5bbf\u547d\u7684\u5b58\u5728\u3002\u800c\u6240\u6709\u770b\u4f3c\u65e0\u5fc3\u7684\u5076\u5f97\u4e4b\u4f5c\uff0c\u80cc\u540e\u90fd\u6709\u7740\u4f5c\u8005\u592f\u5b9e\u7684\u6587\u5b66\u57fa\u7840\u3002",
"account": "\u5916\u6ee9\u753b\u62a5",
"timestamp": "1474774309",
"date": "11:31",
"link": "http:\/\/mp.weixin.qq.com\/s?__biz=MjM5ODA1NzI2MA==&mid=2651838405&idx=3&sn=1316a93a6c272b476173aad6cc9cec79&chksm=bd2bf3868a5c7a90777949be2a656a833478e6e6d2c5e8c1d69adeeeb4536ac53154550141c1&scene=0#rd",
"srclink": "http:\/\/mp.weixin.qq.com\/s?__biz=MjM5ODA1NzI2MA==&mid=2651838405&idx=3&sn=1316a93a6c272b476173aad6cc9cec79&chksm=bd2bf3868a5c7a90777949be2a656a833478e6e6d2c5e8c1d69adeeeb4536ac53154550141c1&scene=0#rd",
"openid": "oIWsFt3hEHhTj8zKvrACLhaCO1m4"
}],
"hotwords": [{
"word": "\u79d1\u6280"
},
{
"word": "\u6559\u80b2"
},
{
"word": "\u517b\u751f"
},
{
"word": "\u5fae\u5546"
},
{
"word": "\u65c5\u884c"
},
{
"word": "\u521b\u4e1a"
},
{
"word": "\u8bdd\u8d39"
}],
"hotnews1": [{
"img": "http:\/\/mmbiz.qpic.cn\/mmbiz_jpg\/wNByw5VpECjhftJI18f00bjJ2z1ODKOD1qiaUrwnZGCZ8bnz3N70wXuZUptrt7wtcPakDU306LrAgoIO71WFtHQ\/640?wx_fmt=jpeg",
"title": "\u5982\u4f55\u907f\u514d\u5728\u65e0\u4ef7\u503c\u7684\u5c0f\u4e8b\u4e0a\u6295\u5165\u592a\u591a\u7cbe\u529b\uff1f",
"account": " warfalcon",
"timestamp": "1474603371",
"link": "http:\/\/mp.weixin.qq.com\/s?__biz=MjM5NjA3OTM0MA==&mid=2655709593&idx=2&sn=1a438a9e0d465f78755a5d605a582951&chksm=bd50fa1a8a27730c42b77185aac09f7415689147ba4562632c983d183e6a056c7fb66a7e92ee&scene=0#rd",
"srclink": "http:\/\/mp.weixin.qq.com\/s?__biz=MjM5NjA3OTM0MA==&mid=2655709593&idx=2&sn=1a438a9e0d465f78755a5d605a582951&chksm=bd50fa1a8a27730c42b77185aac09f7415689147ba4562632c983d183e6a056c7fb66a7e92ee&scene=0#rd",
"openid": "oIWsFtxo3oqejVy4KaJ4RDMVIrE0",
"date": "09\u670823\u65e5"
},
{
"img": "http:\/\/mmbiz.qpic.cn\/mmbiz_jpg\/1HxeD3NxQV8w7jmguvHpvmkc83tYic1KZv3gtpHV94PCCncWb9vHPXvMeiaf7erWXjBSw2oKNJIT109WsaxYkHDQ\/640?wx_fmt=jpeg&tp=webp",
"title": "\u8bb2\u771f\uff0c\u4f60\u8fd9\u6837\u770b\u4e66\u8fd8\u4e0d\u5982\u4e0d\u770b",
"account": "MOOC",
"timestamp": "1474603416",
"link": "http:\/\/mp.weixin.qq.com\/s?__biz=MzA4ODE1NzUxNw==&mid=2651953914&idx=1&sn=86f1029e80009ae0f2b23928efd8027c&chksm=8bcb46d8bcbccfce78e31eb8e20c9646df57103d03d0013f345e5ba084690a6b61f016d5b922&scene=0#rd",
"srclink": "http:\/\/mp.weixin.qq.com\/s?__biz=MzA4ODE1NzUxNw==&mid=2651953914&idx=1&sn=86f1029e80009ae0f2b23928efd8027c&chksm=8bcb46d8bcbccfce78e31eb8e20c9646df57103d03d0013f345e5ba084690a6b61f016d5b922&scene=0#rd",
"openid": "oIWsFt_cFN_RK4tz4VrEL4FEHw80",
"date": "09\u670823\u65e5"
},
{
"img": "http:\/\/mmbiz.qpic.cn\/mmbiz_jpg\/oq1PymRl9D7f1v13DXf4DbWugPaw1VU44ABwCakZia4HoCeNT1xMVibhWicUtOWmry0BZdeVCLDxP8jkwJqic5UoiaA\/640?wx_fmt=jpeg",
"title": "\u6240\u8c13\u7684\u65f6\u5149\u673a\u5668\uff0c\u5e26\u6211\u4eec\u524d\u884c\u7684\u662f\u5bf9\u672a\u77e5\u4e16\u754c\u7684\u5411\u5f80",
"account": "\u592e\u89c6\u65b0\u95fb",
"timestamp": "1474603459",
"link": "http:\/\/mp.weixin.qq.com\/s?__biz=MzA4ODE1NzUxNw==&mid=2651953914&idx=1&sn=86f1029e80009ae0f2b23928efd8027c&chksm=8bcb46d8bcbccfce78e31eb8e20c9646df57103d03d0013f345e5ba084690a6b61f016d5b922&scene=0#rd",
"srclink": "http:\/\/mp.weixin.qq.com\/s?__biz=MzA4ODE1NzUxNw==&mid=2651953914&idx=1&sn=86f1029e80009ae0f2b23928efd8027c&chksm=8bcb46d8bcbccfce78e31eb8e20c9646df57103d03d0013f345e5ba084690a6b61f016d5b922&scene=0#rd",
"openid": "oIWsFt_cFN_RK4tz4VrEL4FEHw80",
"date": "09\u670823\u65e5"
},
{
"img": "http:\/\/mmbiz.qpic.cn\/mmbiz\/5P8dg7GYfMxVSGdC9Oo74q6vibUzuf0gwWgdkIdo5G9K17cibDRegGlevdQh6FIfteo0HFefbySl5D2eEeG2Wxvw\/0?wx_fmt=gif",
"title": "\u5c0f\u767d\u4e5f\u80fd\u61c2\u7684\u51b7\u5149\u7f8e\u767d\u653b\u7565 | \u7259\u9f7f\u62a4\u7406",
"account": "\u5973\u795e\u8fdb\u5316\u8bba",
"timestamp": "1474603520",
"link": "http:\/\/mp.weixin.qq.com\/s?__biz=MzAwODIyMTUyNQ==&mid=2651023833&idx=1&sn=c04603b5399a88cf7d64eea5d8f82759&chksm=8085efe3b7f266f588ee0e2d7145671c145860ce2220ed2ead2429113b83bb8e65a8c26f6dd7&scene=0#rd",
"srclink": "http:\/\/mp.weixin.qq.com\/s?__biz=MzAwODIyMTUyNQ==&mid=2651023833&idx=1&sn=c04603b5399a88cf7d64eea5d8f82759&chksm=8085efe3b7f266f588ee0e2d7145671c145860ce2220ed2ead2429113b83bb8e65a8c26f6dd7&scene=0#rd",
"openid": "oIWsFt_OZoEFApLjga70X4rPDlOM",
"date": "09\u670823\u65e5"
}],
}
}
我需要的是options里面返回的数据样式形式,很多函数的返回值名字都可以相同,重点是里面的数据形式不同。有实际的返回数据形式,就好开发,模拟设置可显示的数据。
因为服务器暂时配不上,所以都由客户端模拟数据返回,我手动只是好符合格式要求的数据,就暂时不需要请求服务器端了。
options里的参数样式能打印一个实例给我们看嘛?复杂一点的,有列表数据和单指数据最好,谢谢
我的意思,如何直接给options里设置返回值,模拟服务器直接返回
嗯,很多资料都没有,很高冷的文档
生命周期函数
onLoad
: 页面加载一个页面只会调用一次。
接收页面参数可以获取
wx.navigateTo
和wx.redirectTo
及<navigator/>
中的 query。https://mp.weixin.qq.com/debug/wxadoc/dev/framework/app-service/page.html?t=201715
由其它页面传入,如:
wx.navigateTo({
url: 'pages/selectCity?city=广州
success: function (res) {
// success
},
fail: function () {
// fail
},
complete: function () {
// complete
}
})
然后在selectCity页面的onLoad就可以
onLoad: function (options) {
console.log('onLoad参数:', options)