【发布时间】:2019-01-02 16:00:42
【问题描述】:
在 Vue.js 中,我使用计算中的这部分代码来计算金额的累积。它在 LocalHost 中运行良好。但是当我将项目上传到 Web 服务器时,这部分代码不起作用。 代码:
personsWithAmount(){
const reducer = (accumulator, currentValue) => accumulator + currentValue.amount;
return this.persons.map((pers)=>{
let p=pers;
if(pers.usercashfloat.length===0){
p.totalAmount=0;
}else if(pers.usercashfloat.length===1){
p.totalAmount=pers.usercashfloat[0].amount;
}else{
window.cashfloat=pers.usercashfloat
p.totalAmount=pers.usercashfloat.reduce(reducer,0);
};
LocalHost 中的结果:
Array 1 =200
Array2 = 200
Result = 400
服务器中的结果
Array 1 =200
Array2 = 200
Result = 200200
谢谢
【问题讨论】: