收藏
回答

数据库取出数据改变页面title(已解决)

RT,求大神解答。

数据库取出的数据如下:

  1. [{0: "彭德怀", 1: "2018.08.30", 2: "中秋佳节促销海报设计",…}]

    1. 0:{0: "彭德怀", 1: "2018.08.30", 2: "中秋佳节促销海报设计",…}

      1. 0:"彭德怀"

      2. 1:"2018.08.30"

      3. 2:"中秋佳节促销海报设计"

      4. 3:"http://pic2.sc.chinaz.com/files/pic/psd1/201808/psd27155.jpg"

      5. 4:"<a href='http://fjdx.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">福建电信下载</a> ↵<a href='http://xmdx.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">厦门电信下载</a> ↵<a href='http://gddx.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">广东电信下载</a> ↵<a href='http://jsdx.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">江苏电信下载</a> ↵<a href='http://fjlt.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">福建联通下载</a> ↵<a href='http://zjlt.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">浙江联通下载</a> ↵<a href='http://xmlt.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">厦门联通下载</a> ↵<a href='http://gdlt.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">广东联通下载</a> ↵<a href='http://fjyd.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">福建移动下载</a> ↵<a href='http://sxyd.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">山西移动下载</a> ↵<a href='http://xmyd.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">厦门移动下载</a> ↵<a href='http://zjyd.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">浙江移动下载</a>"

      6. 5:"36291"

      7. 6:"中秋佳节促销海报设计适用于中秋节海报设计"

      8. 7:"中秋节,中秋海报,月饼,中秋佳节,喜庆,节日素材,活动海报,促销海报,海报设计"

      9. 8:"庆典节日PSD素材"

      10. 9:"24"

      11. 10:"0"

      12. 11:"0"

      13. 12:"0"

      14. 13:"0"

      15. 14:"usertouxiang/pengdiehua.jpg"

      16. biaoqian:"中秋节,中秋海报,月饼,中秋佳节,喜庆,节日素材,活动海报,促销海报,海报设计"

      17. cais:"0"

      18. psd_id:"36291"

      19. psd_leibie:"庆典节日PSD素材"

      20. psd_miaoshu:"中秋佳节促销海报设计适用于中秋节海报设计"

      21. psd_name:"中秋佳节促销海报设计"

      22. psd_spic:"http://pic2.sc.chinaz.com/files/pic/psd1/201808/psd27155.jpg"

      23. psd_time:"2018.08.30"

      24. psd_user:"彭德怀"

      25. psd_xiazai:"<a href='http://fjdx.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">福建电信下载</a> ↵<a href='http://xmdx.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">厦门电信下载</a> ↵<a href='http://gddx.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">广东电信下载</a> ↵<a href='http://jsdx.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">江苏电信下载</a> ↵<a href='http://fjlt.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">福建联通下载</a> ↵<a href='http://zjlt.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">浙江联通下载</a> ↵<a href='http://xmlt.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">厦门联通下载</a> ↵<a href='http://gdlt.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">广东联通下载</a> ↵<a href='http://fjyd.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">福建移动下载</a> ↵<a href='http://sxyd.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">山西移动下载</a> ↵<a href='http://xmyd.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">厦门移动下载</a> ↵<a href='http://zjyd.sc.chinaz.com/Files/DownLoad/psd1/201808/psd27155.rar' target="_blank">浙江移动下载</a>"

      26. scs:"0"

      27. shares:"0"

      28. user_touxiang:"usertouxiang/pengdiehua.jpg"

      29. views:"24"

      30. zans:"0"


js部分代码如下:

Page({

data: {

id: '',

ids: '',

idss: ''

},

onLoad: function (options) {

this.setData({

id: options.id

});

// var idss=this.date.id;

var ids = this.data.id;

var that = this;

wx.request({

url: 'https://www.bbjteam.com/xiaochenxu/bbjteam/index.psdinfo.php',

method: 'POST',

data: {

ids: ids

},

header: {

'content-type': 'application/x-www-form-urlencoded'

},

success: function (res) {

that.setData({

psdinfo: res.data,

});

wx.setNavigationBarTitle({

title: that.data.psdinfo.psd_name

})

}

})

}

})


运行报错:

setNavigationBarTitle:fail parameter error: parameter.title should be String instead of Undefined;


请问大神这个应该如何解决?


最后一次编辑于  2018-12-23
回答关注问题邀请回答
收藏

1 个回答

  • 葱
    2018-12-23

    你这个接口返回的是一个数组格式,而不是直接对象吧?试试

    wx.setNavigationBarTitle({
     
    title: that.data.psdinfo[0].psd_name
     
    })


    2018-12-23
    有用 2
    回复 3
    • 👫月十三
      👫月十三
      2018-12-23

      是数组,试了下你说的方法,控制台报错

      unknown: Unexpected token, expected , 

      2018-12-23
      回复
    • 葱
      2018-12-23回复👫月十三

      这个报错应该和你这个代码片段无关了,查下其它地方代码

      2018-12-23
      1
      回复
    • 👫月十三
      👫月十三
      2018-12-23回复

      还是粗心大意了。修改的时候不小心在上面一行代码多加了字母。谢谢大神。

      2018-12-23
      回复
登录 后发表内容