第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

這些代碼怎樣復(fù)用?

這些代碼怎樣復(fù)用?

qq_殺意隆_0 2017-10-11 14:55:06
這是微信小程序的代碼1.if(!this.data.serveItem){ ?????????????? ????????????????????that.setData({? ????????????????????????loadingHide:false ????????????????????}) ?????????????????????//請求服務(wù)項目列表資源 ????????????????????wx.request({ ????????????????????????url:'https://bird.ioliu.cn/v1?url=http://aasss1.oschina.io/122/4.json', ????????????????????????success(res){ ????????????????????????????that.setData({ ?????????????????????????????????serveItem:res.data, ?????????????????????????????????tireServices:?res.data.tireServices, ?????????????????????????????????maintainServices:?res.data.maintainServices, ?????????????????????????????????installServices:?res.data.installServices, ????????????????????????????}) ????????????????????????????getElementHeight('#item-wrap1',that) ????????????????????????} ????????????????????}) ????????????????}2.if(!this.data.rates){ ????????????????????that.setData({ ????????????????????????loadingHide:false ????????????????????}) ????????????????????//?請求評價列表資源 ????????????????????wx.request({ ????????????????????????url:'https://bird.ioliu.cn/v1?url=http://aasss1.oschina.io/122/2.json', ????????????????????????success(res){ ????????????????????????????that.setData({ ????????????????????????????????rates:res.data.rates ????????????????????????????}) ????????????????????????????getElementHeight('#item-wrap2',that) ????????????????????????} ????????????????????}) ????????????????}3.if(!this.data.recommendList){ ????????????????????that.setData({ ????????????????????????loadingHide:false ????????????????????}) ????????????????????//?請求推薦列表資源 ????????????????????wx.request({ ????????????????????????url:'https://bird.ioliu.cn/v1?url=http://aasss1.oschina.io/122/recommendList.json', ????????????????????????success(res){ ????????????????????????????that.setData({ ????????????????????????????????recommendList:res.data.recommendList ????????????????????????????}) ????????????????????????????getElementHeight('#item-wrap3',that) ????????????????????????} ????????????????????}) ????????????????}上面3段代碼重復(fù)性高,于是我寫了個函數(shù):function?requestResouce(that,oldObj,newObj,url,id){ ????if(!oldObj){ ????????that.setData({ ????????????loadingHide:false ????????}) ????????wx.request({ ????????????url:url, ????????????success(res){ ????????????????that.setData(newObj) ????????????????getElementHeight(id,that) ????????????} ????????}) ????} }結(jié)果代入?yún)?shù)后提示res is not defined。到底要怎樣寫才不會出錯?
查看完整描述

1 回答

?
Gotta

TA貢獻53條經(jīng)驗 獲得超16個贊

控制臺你看你第幾行報錯了。似乎不是你寫的函數(shù)報錯,估計方法調(diào)來調(diào)去,傳參哪里傳錯了。

查看完整回答
反對 回復(fù) 2017-10-11
  • qq_殺意隆_0
    qq_殺意隆_0
    提示res is not defined
  • Gotta
    Gotta
    是啊 提示有一大坨。應(yīng)該有告訴你是哪個方法報錯吧? 比如這樣 abc is not defined;at pages/index/index page test function ReferenceError: abc is not defined 看那個at
  • 1 回答
  • 0 關(guān)注
  • 1046 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號