Houfeng / mditor

📝 [ M ] arkdown + E [ ditor ] = Mditor
http://mditor.com/
533 stars 79 forks source link

Cannot read property 'parse' of undefined #2

Closed lys623 closed 8 years ago

lys623 commented 9 years ago

Cannot read property 'parse' of undefined

var mditor = require("mditor");
var parser = mditor.Parser();
lys623 commented 9 years ago

有没destroy方法

Houfeng commented 9 years ago

少了 new

var parser = new mditor.Parser();
leoskey commented 8 years ago

我使用的0.1.4,node版本是0.12也有这个问题,第一个方法也没有解决这个问题

Houfeng commented 8 years ago

@leoskey 能否提供一些更为详细的信息?

leoskey commented 8 years ago

这次我使用了node 4.*,还是按照你的步骤。先在网页中引入css以及js文件,并new Editor,编辑器正常加载。然后在后端
var mditor = require("mditor");
var parser = mditor.Parser();
使用parser.parse的时候报错

var content = parser.parse(docs[0].report_detail); ^ TypeError: Cannot read property 'parse' of undefined

Houfeng commented 8 years ago

抱歉,这个 issuse 前边的 comment 都有问题,可能误导你了,应该是

var parser = new mditor.Parser(opts);

关键是少了 new