当前位置 : 主页 > 网络编程 > JavaScript >

字符串转jsx.txt

来源:互联网 收集:自由互联 发布时间:2021-06-30
字符串转jsx.txt function stringToJsx(str) { function replace(regex, opt) { regex = regex.source; opt = opt || ''; return function self(name, val) { if (!name) return new RegExp(regex, opt); val = val.source || val; val = val.replace(/(^
字符串转jsx.txt
function stringToJsx(str) {
  function replace(regex, opt) {
    regex = regex.source;
    opt = opt || '';
    return function self(name, val) {
      if (!name) return new RegExp(regex, opt);
      val = val.source || val;
      val = val.replace(/(^|[^\[])\^/g, '$1');
      regex = regex.replace(name, val);
      return self;
    };
  }
  const _tag = "a|abbr|address|area|article|aside|audio|b|base|bdi|bdo"
    + "|big|blockquote|body|br|button|canvas|caption|cite|code|col"
    + "|colgroup|data|datalist|dd|del|details|dfn|dialog|div|dl|dt"
    + "|em|embed|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4"
    + "|h5|h6|head|header|hgroup|hr|html|i|iframe|img|input|ins|kbd"
    + "|keygen|label|legend|li|link|main|map|mark|menu|menuitem|meta"
    + "|meter|nav|noscript|object|ol|optgroup|option|output|p|param"
    + "|picture|pre|progress|q|rp|rt|ruby|s|samp|script|section|select"
    + "|small|source|span|strong|style|sub|summary|sup|table|tbody|td|textarea"
    + "|tfoot|th|thead|time|title|tr|track|u|ul|var|video|wbr|circle|clipPath"
    + "|defs|ellipse|g|image|line|linearGradient|mask|path|pattern|polygon|polyline"
    + "|radialGradient|rect|stop|svg|text|tspan";
  
  let ftag = /<(tag)[^>]+>(.*?)<\/\1>/
  ftag = replace(ftag)
    (/tag/g, _tag)
    ()
}

// function makeHTMLComponent(html) {
//     return React.DOM.div({dangerouslySetInnerHTML: {__html: html}});
// }

// React.renderComponent(makeHTMLComponent("hi there!"), container);


const kkk = `
  77888123
`


const box = (
  
)

Aotoo.render(box, 'test')
网友评论