"//" ......'' //]]>"当"//<![CDATA [" ....."//]]>"用于包装JS代码 [英] "//" ......" //]]>" appears on the page when " //<![CDATA[ " ....."//]]>" are used to wrap a JS code

查看:55
本文介绍了"//" ......'' //]]>"当"//<![CDATA [" ....."//]]>"用于包装JS代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在JSF网页上添加html5拖放上传文件,因此我不得不将此脚本添加到其中

I'm trying to add the html5 drag 'n drop upload file on my JSF web page so i had to add this script into it

<script type="text/html" id="template-uploads">

  //<![CDATA[


      <div data-bind="visible: showTotalProgress()">
            <div>
                <span data-bind="text: uploadSpeedFormatted()"></span>
                <span data-bind="text: timeRemainingFormatted()" style="float: right;"></span>
            </div>
            <div class="uploadimage-totalprogress">
                <div class="uploadimage-totalprogressbar" style="width: 0%;" data-bind="style: { width: totalProgress() + '%' }"></div>
            </div>
        </div>
        <div data-bind="foreach: uploads">
            <div class="uploadimage-upload" data-bind="css: { 'uploadimage-uploadcompleted': uploadCompleted() }">
                <div class="uploadimage-fileinfo">
                    <strong data-bind="text: fileName"></strong>
                    <span data-bind="text: fileSizeFormated"></span>
                    <span class="uploadimage-progresspct" data-bind="visible: uploadProgress() < 100"><span data-bind="text: uploadSpeedFormatted()"></span></span>
                </div>
                <div class="uploadimage-progress">
                    <div class="uploadimage-progressbar" style="width: 0%;" data-bind="style: { width: uploadProgress() + '%' }"></div>
                </div>
            </div>
        </div>

    //]]>
    </script>

如果我删除脚本周围的cdata标签,则会收到此错误:

if i take out the cdata tag which is around my script i get this error :

与元素类型相关联的属性"data-bind"的值 "span"不得包含<"字符.

The value of attribute "data-bind" associated with an element type "span" must not contain the '<' character.

推荐答案

您发布的脚本是一个文本/html脚本,可作为淘汰赛中的模板.该编号对于敲除引用模板是必需的.

The script you've posted is a text/html script which acts as a template in knockout. That id is required for knockout to reference the template.

对于CDATA部分,除非您使用XML,否则可以将其取出.

As for the CDATA sections, unless you're using XML you can take them out.

这篇关于"//" ......'' //]]&gt;&quot;当"//&lt;![CDATA [&quot; ....."//]]>"用于包装JS代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆