收藏
回答

怎么调用另外JS的data数据?


detail.js

Page({

  data: {},

  onLoad: function(options) {

    let postId = options.id

    this.dbPost = new DBPost(postId)

    this.postData = this.dbPost.getPostItemById().data

    this.setData({

      post: this.postData

    })

    this.addReadingTimes()

    // this.setMusicMonitor()

    // this.initMusicStatus()

  },

  onReady: function() {

    wx.setNavigationBarTitle({

      title: this.postData.title

    })

  },

freeTell: function(){

    wx.makePhoneCall({

      phoneNumber:this.postData.phNum,

    success:function(){

      console.log('拨打成功')

    },

    fail:function(){

      console.log('拨打失败')

    }

  })},

data.js

let postList = [

  {phNum:'18602059431'},]


报错makePhoneCall:fail parameter error: parameter.phoneNumber should be String instead of Undefined;


回答关注问题邀请回答
收藏

1 个回答

  • 拾柒
    拾柒
    2020-12-17

    data.js 里通过 export default {}导出,在detail.js引入,然后电话必须是字符串,this.postData.phNum 这里不是,我猜是少了下标,你定义的数据是个数组的嘛


    2020-12-17
    有用 1
    回复
登录 后发表内容
问题标签