- 拔打电话可以其他data.js数组的电话号码怎么弄?
wx.makePhoneCall({ phoneNumber:this.postData.phNum, success:function(){ console.log('拨打成功') }, fail:function(){ console.log('拨打失败') } })}, phoneNumber:this.postData.phNum,后面可以怎么调用其他data里面的电话号码? let postList=[{phNum:'`1122233'},{phNum:'122321312'}] module.exports = { postList: postList };
2020-12-17 - 怎么调用另外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;
2020-12-17 - 函数saveExprs为什么调用错误?
var saveExprs=function(expr){ var exprs=wx.getStorageSync('exprs')||[] exprs.unshift(['expr',expr1]); wx.getStorageSync('exprs',exprs); } Page({ }, data: { temp:"0", lastoper:"+", flag:true, result:"0", id1:"history", id2:"clear", id20:"equ", record:true, expr:"", }, clickButton:function(e) { var data=this.data.result; var tmp=this.data.temp; var lastoperl=this.data.lastoper; var noNumFlag=this.data.flag; var expr1=this.data.expr; if(e.target.id>='num_0' && e.target.id<='num_9'){ data+=e.target.id.split("_")[1]; if(this.data.result=='0'||noNumFlag) { data=e.target.id.split("_")[1]; } noNumFlag=false; }else{ noNumFlag=true; console.log(e.target.id); if(e.target.id=="dot"){ if(data.toString().indexOf(".")==-1) { data+="."; } }else if(e.target.id=="clear"){ expr1=expr1.substr(0,expr1.length-1)+"="+tmp; // if (this.data.record) { // wx.setStorageSync('expr', expr1) // } saveExprs(expr1); expr1=""; data=0; tmp=0; lastoperl="+"; } })
2020-08-30