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="+";
}
})
语法错误吧
你报 saveExprs is not a function 我就有点懵逼了
先检查下saveExprs 有没有有重名?saveExprs
另外我觉得你 saveExprs 函数里面 getStorageSync 第二个写法有问题!
为什么提示saveExprs不是一个函数
at ye.clickButton (http://127.0.0.1:43195/appservice/pages/caculate/caculate.js:105:9)
at Object.r.safeCallback (WAService.js:1:1125173)
at WAService.js:1:1317978
at r (WAService.js:1:1249680)
at WAService.js:1:1249802
at WAService.js:1:420977
at o (http://127.0.0.1:43195/appservice/__dev__/asdebug.js:1:28054)
at e.exports.
at http://127.0.0.1:43195/appservice/__dev__/asdebug.js:1:1844
at Array.forEach (