我正在尝试使用来自Github的这个脚本,网址为https://github.com/blueimp/jQuery-File-Upload
该脚本有js代码之类的
<script id="template-upload" type="text/html">
{% for (var i=0, files=o.files, l=files.length, file=files[0]; i<l; file=files[++i]) { %}
<tr class="template-upload fade">
<td class="preview"><span class="fade"></span></td>
<td class="name">{%=file.name%}</td>
<td class="size">{%=o.formatFileSize(file.size)%}</td>
{% if (file.error) { %}
<td class="error" colspan="2"><span class="label important">Error</span> {%=fileUploadErrors[file.error] || file.error%}</td>
{% } else if (o.files.valid && !i) { %}
<td class="progress"><div class="progressbar"><div style="width:0%;"></div></div></td>
<td class="start">{% if (!o.options.autoUpload) { %}<button class="btn primary">Start</button>{% } %}</td>
{% } else { %}
<td colspan="2"></td>
{% } %}
<td class="cancel">{% if (!i) { %}<button class="btn info">Cancel</button>{% } %}</td>
</tr>
{% } %}
</script>
Run Code Online (Sandbox Code Playgroud)
{%
或者%}
是什么意思?id
?有什么用,我以前从未见过它?type="text/html"
是什么意思?我一直都在使用
type="text/javascript"
.没什么,你不是在写javascript,你只是在写一些看起来很像javascript的东西.
注意这条线
<script id="template-upload" type="text/html">
Run Code Online (Sandbox Code Playgroud)
如果您正在编写javascript,那么类型将是text/javascript
(或者在html5中,您可以省略所假设的类型).
所以回答你的三个问题:
{% ... %}
,好像它是javascript."<div>
和<input>
元素是.