关于express制作多人博客是出现的问题,报如下错误,求高手解答下,多谢了
发布于 8 年前 作者 FantasyGao 3188 次浏览 来自 问答

E:\mynode\blog\node_modules\mongodb\lib\utils.js:97 process.nextTick(function() { throw err; }); ^

TypeError: Cannot read property ‘slice’ of undefined at convert_tree_to_html (E:\mynode\blog\node_modules\markdown\lib\markdown.j s:1556:20) at Object.toHTMLTree (E:\mynode\blog\node_modules\markdown\lib\markdown.js:1 12:14) at Object.toHTML (E:\mynode\blog\node_modules\markdown\lib\markdown.js:82:22 ) at E:\mynode\blog\models\post.js:90:33 at Array.forEach (native) at E:\mynode\blog\models\post.js:89:16 at handleCallback (E:\mynode\blog\node_modules\mongodb\lib\utils.js:95:12) at E:\mynode\blog\node_modules\mongodb\lib\cursor.js:772:16 at handleCallback (E:\mynode\blog\node_modules\mongodb\node_modules\mongodb- core\lib\cursor.js:244:5) at setCursorDeadAndNotified (E:\mynode\blog\node_modules\mongodb\node_module s\mongodb-core\lib\cursor.js:548:3)

5 回复

你只提交这个 看不出任何问题呢

at E:\mynode\blog\models\post.js:90:33 你看看这个文件的 90行左右 有没有关于slice的方法 目测你的数组是undefined

@yanglinnie 应该是使用markdown这个模块时出现的问题,因为是新手第一次用这个模块, docs.forEach(function (doc) { doc.post = markdown.toHTML(doc.post); });
想把数据库里发表的文章装换为html展示出来 docs.forEach(function (doc) { //doc.post = markdown.toHTML(doc.post); });
当我注释这句的时候,就不会在后台报错误了。

@coolfishstudio doc.post = markdown.toHTML(doc.post); 这就是90行的代码

@FantasyGao 嗯 推荐你在这一步处理前 看看doc.post 我倾向这个数据有问题

回到顶部