我已经为此工作了 4 个小时,阅读了许多相关的解释并尝试了其中的几个。我确定我错过了一个简单的概念并修复了这个错误。非常感谢您的帮助。
ColorChart.setupAnswerChoices();
"setupAnswerChoices": function() {
var currentChoiceList = sessionStorage.getItem("NE_CURRENT_CHOICE_LIST");
var baseChoiceList = currentChoiceList.slice();
console.log ("baseChoiceList " + baseChoiceList);
baseChoiceList 12,17,1,22,27,NCN
consol.log ("currentChoiceList " + currentChoiceList);
当前选择列表 12,17,1,22,27,NCN
var what = Object.prototype.toString;
console.log("buttonChoice " + what.call(buttonChoice));
buttonChoice [对象数组]
console.log("baseChoiceList " + what.call(baseChoiceList));
baseChoiceList [对象字符串]
var buttonChoice = [];
for (var i = 0; i < 5; i++) {
var randomButtonIndex = Math.floor(Math.random() * (5 - i));
buttonChoice = baseChoiceList.splice(randomButtonIndex,1);
}
未捕获的类型错误:baseChoiceList.splice 不是函数