【问题标题】:./node_modules/@selderee/plugin-htmlparser2/lib/hp2-builder.mjs Attempted import error: 'Picker' is not exported from 'selderee'./node_modules/@selderee/plugin-htmlparser2/lib/hp2-builder.mjs 尝试导入错误:“Picker”未从“selderee”导出
【发布时间】:2021-11-14 21:47:24
【问题描述】:

当我要导入 htmlToText 包时出现此错误

import { htmlToText } from 'html-to-text';

然后我得到了这个错误

./node_modules/@selderee/plugin-htmlparser2/lib/hp2-builder.mjs
Attempted import error: 'Picker' is not exported from 'selderee'.

【问题讨论】:

  • 你试过用require代替import吗?
  • 但是我在react中使用这个包,我怎么能用require代替import,

标签: javascript html reactjs npm npm-package


【解决方案1】:

我遇到了同样的问题。如果你有一个完整的 React 应用程序,这对我有用。
在 Axios 请求的正文中将 html 从前端发送到后端。在您的 API 端点调用 html-to-text,然后将响应发送回您将使用它的前端

【讨论】:

  • 如果没有后端有什么解决办法吗?
  • 可能有,但我找不到 :( 试试不同的包?
  • @LakinduHewawasam 或者您可以在此答案中使用 RegEx:\ var htmlString = "<h1><b>test</b></h1>"\ var plainString = htmlString.replace(/<[^>]+>/g, '');\ console.log(plainString ); // you will have your plain text\ [link] (stackoverflow.com/questions/63574937/…)
  • 哦,好吧,我试试看!
【解决方案2】:

就我而言,我的 html-to-text 版本是 7.0.0

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-24
    • 2020-07-16
    • 1970-01-01
    • 1970-01-01
    • 2019-06-06
    • 2020-06-26
    • 2019-10-24
    • 2021-10-20
    相关资源
    最近更新 更多