错误提示:Argument of type 'number' i
2018-08-30 本文已影响0人
HappyforSuzy
错误提示:Argument of type 'number' is not assignable to parameter of type 'string'.
解决方法1: toString
//第一次遇到
var qishuyear= qishudate.getFullYear().toString(); //获取完整的年份(4位,1970)
var qishumonth=(qishudate.getMonth()+1).toString(); //获取当前月份(0-11,0代表1月)
var qishuday=qishudate.getDate().toString(); //获取当前日(1-31)
//第二次遇到
var ApiUrl = AppConfig.ENV('api')+'order';
let headers = new Headers();
headers.append('Content-Type', 'application/x-www-form-urlencoded');
let options = new RequestOptions();
let body = new FormData();
body.append('number',number.toString());
body.append('bet',bet.toString());
body.append('multiple',multiple.toString());
解决方法1: 把javascript代码改为angularjs
//从0-10的随机数
错误写法:$random=parseInt(Math.random()*10);
$scope.random=Math.floor(Math.random()*10);
//PS: 从1-10的随机数
$scope.random=Math.floor(Math.random()*10+1);