一、赋值https://www.jianshu.com/p/19156f9fac1e
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/> <meta name="format-detection" content="telephone=no,email=no,date=no,address=no"> <title>云API</title> <link rel="stylesheet" type="text/css" href="../css/api.css"/> <link rel="stylesheet" type="text/css" href="../css/style.css"/> </head> <body> <header> </header> <div id="show_list"></div> </body> <script src="https://cdn.bootcss.com/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript" src="script/api.js"></script> <script src="https://cdn.bootcss.com/dot/1.1.2/doT.min.js"></script> <script id="tpl" type="text/x-dot-template"> <div>Hi {{=it.name}}!</div> <div>{{=it.age || ''}}</div> </script> <script type="text/javascript"> apiready = function () { var data = {"name":"Jake","age":31}; var show_tpl = doT.template($("#tpl").text()); //$("#show_list").html(show_tpl(data)); //jq 方式 $api.html($api.byId('show_list'),show_tpl(data)) } </script> </html>