国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

微信小程序開發(fā) -- 踩坑

2019-11-09 18:38:45
字體:
供稿:網(wǎng)友

自學(xué)微信小程序,用小程序做了個小項目,踩了一些坑:

坑一:

Navigated to http://1755603039.appservice.open.weixin.QQ.com/appserviceVM2507:1 Sat Feb 04 2017 21:46:27 GMT+0800 (中國標準時間) 渲染層錯誤VM2507:2 SyntaxError: Invalid or unexpected token(anonymous) @ VM2507:2VM2509:1 Sat Feb 04 2017 21:46:27 GMT+0800 (中國標準時間) 渲染層錯誤VM2509:2 webviewScriptErrorInvalid or unexpected tokenSyntaxError: Invalid or unexpected token(anonymous) @ VM2509:2VM2510:1 Sat Feb 04 2017 21:46:27 GMT+0800 (中國標準時間) 渲染層錯誤VM2510:2 Uncaught SyntaxError: Invalid or unexpected token(anonymous) @ VM2510:2VM2511:1 Sat Feb 04 2017 21:46:27 GMT+0800 (中國標準時間) 渲染層錯誤VM2511:2 ReferenceError: $gwx is not defined    at 1755603039.debug.open.weixin.qq.com/pages/index/index.html:1438(anonymous) @ VM2511:2VM2512:1 Sat Feb 04 2017 21:46:27 GMT+0800 (中國標準時間) 渲染層錯誤VM2512:2 webviewScriptError$gwx is not definedReferenceError: $gwx is not defined    at http://1755603039.debug.open.weixin.qq.com/pages/index/index.html:1438:27(anonymous) @ VM2512:2VM2513:1 Sat Feb 04 2017 21:46:27 GMT+0800 (中國標準時間) 渲染層錯誤VM2513:2 Uncaught ReferenceError: $gwx is not defined

出現(xiàn) $gwx is not defined

提示報錯位置 at http://1755603039.debug.open.weixin.qq.com/pages/index/index.html:1438:27

這個報錯位置提示沒有任何意義,因為index.whtml我好幾天沒有動過了;

這個錯誤后來發(fā)現(xiàn)  在剛改過的whtml 頁面 想寫"¥{{user.salary}}/時 "   結(jié)果寫成了"${{user.salary}}/時" , 將 ¥ 寫成了$;

坑二

封裝了一下微信提供的網(wǎng)絡(luò)訪問接口,結(jié)果服務(wù)器端死活獲取不到傳遞的參數(shù),最后上網(wǎng)一查,post請求的header必須將content-type設(shè)置為 'application/x-www-form-urlencoded',否則后臺就接收不到數(shù)據(jù),而我設(shè)置的是'application/json' ,沒有其它原因,因為我就是想傳遞json數(shù)據(jù)啊,另外POST必須要大寫,這點接口文檔上寫了,正確代碼如下:

function request(param) {     var obj ={        url: param.url,        header: {            'content-type': 'application/x-www-form-urlencoded', /****注意:post方式必須這樣設(shè)置,否則后臺獲取不到參數(shù) */            /***'content-type': 'application/json',**/        },        method:'POST',/***注意post必須大寫 */        data:param.data==undefined ? "":param.data,        success: function( res ) {            /**console.log(res.data); */            if(param.success && typeof(param.success) =="function" ){                param.success(res);            }        },        fail: function( res ) {           if(param.fail && typeof(param.fail) =="function" ){                param.fail(res);            }        }     }     if(app.globalData.token){         obj.header.access=app.globalData.token;     }     /**     console.log( obj.url)     console.log(JSON.stringify(obj.data) );      */     wx.request(obj);     }


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 株洲县| 抚州市| 唐河县| 黄石市| 金阳县| 郯城县| 合作市| 建宁县| 沙雅县| 望江县| 保亭| 台安县| 嵊泗县| 泰来县| 昌都县| 枞阳县| 洛川县| 青岛市| 岳池县| 东乌珠穆沁旗| 鄄城县| 山阳县| 镇坪县| 美姑县| 灌阳县| 化德县| 巴林右旗| 凤冈县| 梓潼县| 马山县| 阳新县| 平遥县| 札达县| 兴义市| 新余市| 江安县| 贺州市| 手机| 巴里| 嘉峪关市| 东安县|