admin管理员组文章数量:1429433
I'm trying to convert HTML to Markdown in a Vue-application.
I'm trying to implement Turndown, but I'm getting the error, in the console:
TypeError: TurndownService is not a constructor
I'm using Webpack, to pile it. This is the vue-ponent I'm trying to use it in:
<script>
var TurndownService = require('turndown');
console.log( new TurndownService() ); // Returns 'undefined';
export default {
mounted() {
var turndownService = new TurndownService();
this.markdownContent = turndownService.turndown(
'<a href="">A link</a><p>Hello world</p>'
);
},
...
...
This is what it looks like in node_modules:
I've tried all kind of things, to solve it. Based on this, I tried
var TurndownService = require('turndown').TurndownService;
and
var TurndownService = require('turndown/dist/turndown').TurndownService;
... But no cigar. :-/
I'm trying to convert HTML to Markdown in a Vue-application.
I'm trying to implement Turndown, but I'm getting the error, in the console:
TypeError: TurndownService is not a constructor
I'm using Webpack, to pile it. This is the vue-ponent I'm trying to use it in:
<script>
var TurndownService = require('turndown');
console.log( new TurndownService() ); // Returns 'undefined';
export default {
mounted() {
var turndownService = new TurndownService();
this.markdownContent = turndownService.turndown(
'<a href="https://example">A link</a><p>Hello world</p>'
);
},
...
...
This is what it looks like in node_modules:
I've tried all kind of things, to solve it. Based on this, I tried
var TurndownService = require('turndown').TurndownService;
and
var TurndownService = require('turndown/dist/turndown').TurndownService;
... But no cigar. :-/
Share Improve this question asked Apr 10, 2019 at 20:39 ZethZeth 2,64010 gold badges61 silver badges121 bronze badges1 Answer
Reset to default 9Found your post while dealing with the same.
This fixed it for me:
const TurndownService = require('turndown').default;
After that, the regular instructions worked like a charm!
本文标签: javascriptUsing Turndown in VueTypeError TurndownService is not a constructorStack Overflow
版权声明:本文标题:javascript - Using Turndown in Vue - TypeError: TurndownService is not a constructor - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745412543a2657536.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论