添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
打篮球的红酒  ·  解决GNU ...·  1 年前    · 
俊秀的面包  ·  linux c++编程 - 掘金·  1 年前    · 
很酷的山楂  ·  [UE4] ...·  1 年前    · 
爱热闹的莲藕  ·  Linux 之 HTML ...·  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​