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

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

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

2019-11-09 19:07:27
字體:
供稿:網(wǎng)友

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

坑一:

Navigated to http://1755603039.appservice.open.weixin.QQ.com/appserviceVM2507:1 Sat Feb 04 2017 21:46:27 GMT+0800 (中國標(biāo)準(zhǔn)時間) 渲染層錯誤VM2507:2 SyntaxError: Invalid or unexpected token(anonymous) @ VM2507:2VM2509:1 Sat Feb 04 2017 21:46:27 GMT+0800 (中國標(biāo)準(zhǔn)時間) 渲染層錯誤VM2509:2 webviewScriptErrorInvalid or unexpected tokenSyntaxError: Invalid or unexpected token(anonymous) @ VM2509:2VM2510:1 Sat Feb 04 2017 21:46:27 GMT+0800 (中國標(biāo)準(zhǔn)時間) 渲染層錯誤VM2510:2 Uncaught SyntaxError: Invalid or unexpected token(anonymous) @ VM2510:2VM2511:1 Sat Feb 04 2017 21:46:27 GMT+0800 (中國標(biāo)準(zhǔn)時間) 渲染層錯誤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 (中國標(biāo)準(zhǔn)時間) 渲染層錯誤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 (中國標(biāo)準(zhǔn)時間) 渲染層錯誤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ā)表
主站蜘蛛池模板: 盐山县| 桓仁| 宁南县| 忻城县| 巧家县| 朔州市| 万载县| 内黄县| 渑池县| 保定市| 隆回县| 裕民县| 灵璧县| 桃江县| 延安市| 库尔勒市| 盈江县| 江陵县| 延寿县| 保山市| 屏南县| 沁源县| 临颍县| 电白县| 竹溪县| 饶平县| 大英县| 恩施市| 旬邑县| 靖远县| 昌都县| 兖州市| 当阳市| 济阳县| 太保市| 南岸区| 定日县| 平武县| 岚皋县| 师宗县| 平和县|