【问题标题】:Reactjs:'html-to-react' parser errorReactjs:'html-to-react'解析器错误
【发布时间】:2017-11-02 10:33:52
【问题描述】:

ReactJS 中使用html-to-react 解析器时出现错误

我遇到了一个错误

“_htmlToReact.HtmlToReactParser 不是构造函数”。

我已将'HtmlToReactParser' 导入为

import {HtmlToReactParser} from 'html-to-react'

【问题讨论】:

  • 你有什么问题?

标签: javascript reactjs npm html-parsing


【解决方案1】:

使用 ES6 样式的导入,您需要将其导入为

import {Parser as HtmlToReactParser} from 'html-to-react'.

相当于

var HtmlToReactParser = require('html-to-react').Parser;

在文档中提到的 commonJS

【讨论】:

  • 很高兴有帮助:)
猜你喜欢
  • 2010-11-26
  • 1970-01-01
  • 2019-06-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-28
  • 1970-01-01
  • 2019-02-19
相关资源
最近更新 更多