我正在使用Node.js使用cheerio模块清理一些HTML元素。我正在尝试使用该模块,以便我可以将标记解析为DOM元素。我希望能够做的是将文本输入到表单的textarea字段中,当我在textarea中添加HTML元素作为字符串时,我希望将该HTML字符串呈现为实际的DOM元素
exports.createStore = async (req, res) => {
req.body.author = req.user._id;
const store = await new Store(req.body).save();
const $ = cheerio.load(store.description);
$(store.description).text();
console.log($(store.description).text());
await store.save();
req.flash(
"success",
`Successfully Created ${store.name}. Care to leave a review?`
);
res.redirect(`/store/${store.slug}`);
};
其中store.description =' Hello< B个世界< / B个'
我希望store.description等于Hello World