87,993
社区成员
发帖
与我相关
我的任务
分享<body>
<div>
<label>姓名:</label> <input type="text" placeholder="请输入姓名"
v-model="name">
</div>
<!-- Javascript -->
<script src="js/jquery-1.8.2.min.js"></script>
<script src="js/vue.js"></script>
</body>
<script type="text/template">
<tr mgid="{mgid}" mid="{mid}">
<td>
<input type="checkbox" mid="{mid}"></td>
<td>
<a href="{localfile}" data-fancybox-group="button" class="fancybox-buttons">
<img src="{localfile}" style="width:45px;height:45px;"></a>
</td>
<td>
<input type="text" class="input-large valid" value="{medianame}" onblur="TextOnBlur(this)" onclick="TextOnFocus(this)" name="medianame" mid="{mid}" readonly="readonly"></td>
<td>{mediatype}</td>
<td>
<a onclick="updateMediaName(this)" href="javascript:void(0);">重命名</a>
<a onclick="showbulkUploadTemplate(this)" name="edit" localfile="{localfile}" href="javascript:void(0);">替换</a>
<a onclick="daleteMedia(this)" href="javascript:void(0);">删除</a>
<a onclick="setMediaFaceImage(this);" title="设置为分组【{groupname}】的封面" groupname="{groupname}" mid="{mid}" href="javascript:void(0);">设置封面</a>
</td>
</tr>
</script>
<script type="text/javascript">
function formatTemplate(dta, tmpl) {
var format = {
name : function(x) {
return x;
}
};
return tmpl.replace(/{(\w+)}/g, function(m1, m2) {
if (!m2)
return "";
return (format && format[m2]) ? format[m2](dta[m2]) : dta[m2];
});
}
$(document).ready(function() {
var dta = {
"total" : "1",
"page" : "1",
"records" : "3",
"rows" : [ {
"groupname" : "美食图片",
"mid" : 4766,
"sid" : 517,
"medianame" : "哈哈哈",
"mgid" : 549,
"mediatype" : "哈哈哈",
"mediaid" : "",
"timestamp" : "",
"localfile" : "/UploadFile/image/201409/14/0x6dvf.jpg",
"picurl" : "",
"thumbid" : "",
"voiceformat" : "",
"state" : 1,
"createtime" : "\/Date(1410673220000+0800)\/",
"uploadtime" : "\/Date(1410673220000+0800)\/",
"width" : 480,
"height" : 360,
"seizespace" : 17.41
} ]
};
//获取模板上的HTML
var html = $('script[type="text/template"]').html();
//定义一个数组,用来接收格式化合的数据
var arr = [];
//对数据进行遍历
$.each(dta.rows, function(i, o) {
//这里取到o就是上面rows数组中的值, formatTemplate是最开始定义的方法.
arr.push(formatTemplate(o, html));
});
//好了,最后把数组化成字符串,并添加到table中去。
$('#tableData').append(arr.join(''));
});
</script>