小程序 403

開發小程序遇到的問題

小程序項目結構json

*pages //業務集小程序

*utils //公共集,經過require() 調用跨域

app.js //主程序,能夠定義整個小程序的生命週期及公共方法\全局變量,經過var app = getApp();app.調用數組

app.json//主配置,配置小程序是由哪些頁面組成,配置小程序的窗口背景色,配置導航條樣式,配置默認標題。注意該文件不可添加任何註釋。服務器

app.wxss//公共樣式表app

 

  1. 鏈接報403 Forbidden:跨域問題,在服務器設置head:Access-Control-Allow-Origin 例:response.setHeader("Access-Control-Allow-Origin", "*");
  2. JSON.parse(string) SyntaxError: Unexpected token ' in JSON at position :格式問題,{img:http://..},{"img":http://..}都要改成 {"key":"value"} 例:{"img":"http://.."}
  3. 拼接字符串可使用``,變量使用${}輸出,例:var data=`{"img":"${url}"}`
  4. scroll-view>scroll-into-view 定位不許,使用unshift 在數組最前面插入數據
  5. <input type="text" value="{{inputValue}}" bindinput="binginput"/> inputValue能夠控制input內容,在input輸入內容inputValue不會改變,定義,Page中定義binginput:function(e){this.setData({inputValue:e.detail.value})}
相關文章
相關標籤/搜索