刚接触小程序,自己写一个页面,初始化的时候加载缓存数据,当缓存数据不存在的时候请求。
然后在请求中初始化数据,返回 o.complete is not a functon
var config = require('../../utils/config.js');var page = 0;var limit = 10;var get_info_data = function(that){ wx.request({ url: config.host + '/index/user/info_list', data:{ page:page, limit:limit, }, header:{ 'Content-type':'application/json', }, success:function(res){ var datas = res.data; if (datas.code == 200){ var info_data = wx.getStorageSync('info_data') || []; wx.setStorageSync('info_data', datas.data); that.setData({ info_data: datas.data, info_data_state:true, },800); page++; } }, fail:function(){ }, complete:function(){ } });};Page({ /** * 页面的初始数据 */ data: { info_data:[], info_data_state: false, background: ['demo-text-1', 'demo-text-2', 'demo-text-3'], autoplay:true, indicatorDots:false, interval:2000, duration:1500, anshun: true,//导航选中 luke: false,//导航选 timeout:false,//导航选中 title_anshun:'A', title_luke:'b', title_timeout:'c', }, anshun: function (e) { this.setData({ anshun: true, luke: false, timeout:false, }) }, luke: function (e) { this.setData({ anshun: false, luke: true, timeout: false, }) }, timeout: function (e) { this.setData({ anshun: false, luke: false, timeout: true, }) }, onShow:function(){ // 初始化数据 从缓存中读取用户角色信息 try{ var info_data = wx.getStorageSync('info_data'); console.log(info_data) if(info_data){ this.setData({ info_data:info_data, info_data_state:true, }) }else{ get_info_data(this); } }catch(e){} }}) |
错误提示
VM1303:1 TypeError: o.complete is not a function at http://127.0.0.1:64951/appservice/__dev__/WAService.js:7:29321 at e.(anonymous function) (http://127.0.0.1:64951/appservice/__dev__/WAService.js:3:29569) at a (http://127.0.0.1:64951/appservice/appservice:1003:9451) at e.registerCallback (http://127.0.0.1:64951/appservice/appservice:1003:9638) at m.forEach (http://127.0.0.1:64951/appservice/appservice:1003:5612) at Array.forEach ( at d (http://127.0.0.1:64951/appservice/appservice:1003:5592) at WebSocket.j.onmessage (http://127.0.0.1:64951/appservice/appservice:1003:5485)console.error @ VM1303:1m.forEach @ VM1308 appservice:1003d @ VM1308 appservice:1003j.onmessage @ VM1308 appservice:1003 |
新手求解

setData参数错误:“800”
3Q,已解决