1. 程式人生 > >milo的template模板引擎

milo的template模板引擎

1.首先要引入milo

2.模板中要放一個textarea,並且設定display:none,設定一個id

3,填充的時候,把這個rAdminDetail放到AdminDetail裡面去。(注意:寫的時候,不能用AdminDetail包著要填空的模板結構)

   <div class="main-b22" style="display: none;">
                <div id="AdminDetail" ></div>
				<textarea style="display:none" id="rAdminDetail">
					<div class="coupon-box">
                        <div>
                        	{for v in UserMission}
                            <i class="tic-type">${v.iTypeStr}</i>
								{if v.iType == "0" }
								  <a class="btn-useyhq" href="javascript:DoEnd('${v.vMissionExch}','${v.vMission}','${v.vSession}');" onclick="pgvSendClick({hottag:'act.a20181214cityfiesta.btn.useyhq'})">確認核銷</a>
								{else}
								  <a class="btn-useyhq" href="javascript:;" >${v.dtDoneTime}由${v.vMissionExch2}核銷 </a>
								{/if}
                            {/for}
                        </div>
                        <ul class="user-message">
                        	{for p in Private}
                            <li>
                                <p>姓名:</p>${p.vName}
                            </li>
                            <li>
                                <p>證件型別:</p>身份證
                            </li>
                            <li>
                                <p>手機號:</p>${p.vPhone}
                            </li>
                            <li>
                                <p>證件號碼:</p>${p.vCard}
                            </li>
                            	{/for}
                        </ul>
                    </div>
				</textarea>
            </div>
        </div>

 

4.js中的處理 

  need("util.template", function(template) {

      var t = template.parseDOMTemplate("rAdminDetail");
      $("#AdminDetail").html(t.process(data));
                          

   });