zoukankan      html  css  js  c++  java
  • jsonx 基于json 创建react 组件

    jsonx 是一个不错的工具包,我们可以用来方便的创建react 的组件,是不个很不错就有json 开发web引用的选择工具

    一个demo

    具体index.web.js可以在官方的dist 目录找到

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="utf-8">
        <title>JSONX TEST</title>
        <script type="text/javascript" src="index.web.js"></script>
      </head>
      <body>
        <div id="root"></div>
        <script type="text/javascript">
          const sampleJSONX = {
            component: 'div',
            props: {
              id: 'generatedJSONX',
              className:'jsonx',
            },
            children: [
              {
                component: 'p',
                props: {
                  style: {
                    color: 'red',
                    fontWeight:'bold',
                  },
                },
                __dangerouslyEvalProps:{
                  onClick:'()=>alert("click works")'
                },
                children:'hello world',
              },
            ],
          };
          const boundConfig = {
            debug:true, 
          };
          jsonx.jsonxRender.call(boundConfig,{ jsonx: sampleJSONX, querySelector:'#root', });
        </script>
      </body>
    </html>
     
     

    参考资料

    https://github.com/repetere/jsonx#readme

  • 相关阅读:
    python程序2:购物车
    挖矿病毒watchbog处理过程
    docker从入门到精通再到放弃
    python基础应用---列表应用
    python基本应用--三元应用
    由java派生出来的证书错误
    python基础应用---格式化输出
    test04
    在博客中模拟Typora中的Dark风格
    Test03 TextBox
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/13376700.html
Copyright © 2011-2022 走看看