mpvue笔记(view:3111)

1.官方文档
http://mpvue.com/mpvue/quickstart/
2.其他资料
https://www.v2ex.com/amp/t/447109
http://www.bslxx.com/m/view.php?aid=1824

3.问题笔记
一.wx.request请求时候this取不到值

  1. data () {
  2. return {
  3. questionlist: []
  4. }
  5. },
  6. methods: {
  7. getData () {
  8. var that = this //这个地方非常重要,重置data{}里数据时候setData方法的this应为以及函数的this, 如果在下方的sucess直接写this就变成了wx.request()的this了
  9. wx.request({
  10. url: 'getData.php',
  11. data: {},
  12. header: {
  13. 'content-type': 'application/json'
  14. },
  15. success: function (res) {
  16. that.questionlist = res.data
  17. }
  18. })
  19. }
  20. },
  21.  
  22. created () {
  23. // 页面加载时调用
  24. this.getData()
  25. }