添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
大力的荒野  ·  #167: argument of ...·  1 月前    · 
果断的针织衫  ·  Error E0310 - I'm a ...·  1 月前    · 
爱看球的海龟  ·  use c++ in keil not ...·  1 月前    · 
坚强的蘑菇  ·  Nuxt3配置入門 - HackMD·  2 周前    · 
豪气的眼镜  ·  从JDK 8升级到JDK ...·  1 年前    · 
爱看球的梨子  ·  js ...·  2 年前    · 
import React from 'react'
import { html2json, json2html } from 'html2json'

export default function Index() {
const data = `<p></p>
<div style="text-align:right;"><img src="http://test-images.qi.work/course/2021-07-01/bbbe7816252340aa8049bcab3b0370ac.jpg" alt="image" style="height: auto;width: auto"/></div>
<p></p>`

const htmlFormat = (data) => {
const json = html2json(data)
console.log(json)
const html = json2html(json)
return html
}

const result = htmlFormat(data)
console.log(result)

return <div>1</div>
}

html转json json转html_html

参考链接:​ ​https://github.com/Jxck/html2json​