我有一个角度函数,它从GET请求中接收一个数字,然后将该数字编码为基数64。我正在尝试使用概述为here的padStart函数,但是当我在调用该函数后记录该字符串时,该字符串没有被填充。你知道为什么吗?
角度:
$scope.generateCode = function(){
var number = autogenNumber(); //Pull the number
number.then(function (result) { //Then increment up and convert
var working_str = result.toString();
console.log("The pre padded string is", working_str);
working_str.padStart(8, '1234');
console.log("The padded string is now", working_str, typeof working_str);
})
};
发布于 2018-06-05 06:07:50
字符串是不可变的。你必须重新分配
working_str = working_str.padStart(8, '1234');
https://stackoverflow.com/questions/50689369
复制相似问题