输入:为什么我在下面的ES6 for循环中得到“undefined不是函数”?
first line
second line third line
fourth line
的代码:
let res = str.split('\n\n')
for (let result of res) {
res = `<p class="blockquote">${res.replace(/^> /gm, '')}</p>`
}
console.log(`text: ${res}`)
str.split('\n\n')
输出first line,second line third line,fourth line
。我的预期。
现在我想使用for
循环来取每个项目并用p
标记包围它。然而,我得到以下错误:
TypeError: undefined is not a function
我对ES6不是很有经验。循环有问题吗?
什么是你想到底要得到什么?四个字符串包装在blockquote标签中的数组?你能显示所需的输出吗? – Touffy