我有一个返回以下内容的数组:
["↵Onprogress↵Done"]
我想删除这个符号:'↵'。
正如您在下面的代码中所见,我已经尝试了各种方法。我尝试将变量调用为从数组中过滤变量的箭头的值。或者声明第二个空数组,然后遍历第一个数组并将我想要的内容推送到第二个数组。我开始怀疑这是否是控制台默认返回的内容?如果有人能帮助我,我将不胜感激。另请记住,当我按索引返回数组时,它会给我“未定义”。
addCardtoApp = event => {
event.preventDefault();
const card = {
taskName: this.taskName.current.value,
taskDescription: this.taskDescription.current.value,
taskPeriod: this.taskPeriod.current.value,
};
const cardStatus = this.taskStatus.current.value;
let otherStatus = {
otherStatus: this.taskStatus.current.innerText,
};
// otherStatus = otherStatus.otherStatus.replace('↵', '');
const replacedStatus = otherStatus.otherStatus.replace(`${cardStatus}`, '');
const convertedStatus = replacedStatus.split(' ');
// let annoyingArrow = '↵'
// console.log('↵')
// let refinedStatus = convertedStatus
// refinedStatus = refinedStatus.filter( item => item !== 'Todos' || 'Onprogress' || 'Done');
let refinedStatus = []
convertedStatus.forEach(function(item) {
if (item === 'Todos' || 'Onprogress' || 'Done') { refinedStatus.push(item) };
})
console.log(refinedStatus);
this.props.addCard(card, cardStatus, refinedStatus);
event.currentTarget.reset();
};
最佳答案
const arr = ["↵Onprogress↵Done"];
const newArray = JSON.parse(JSON.stringify(arr).replace(/↵/g, ''));
关于javascript - 从数组中删除不需要的符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57102571/