【问题标题】:html grunt-minified angular form submit button not rendering (node)html grunt-minified angular form提交按钮不呈现(节点)
【发布时间】:2016-01-29 15:39:27
【问题描述】:

提供源文件时,以下角度表单正确呈现,并且按钮在按下时正确提交(我已减小表单的大小以保持简洁)

<form class="form-horizontal ng-submit="entry.addEntry()" novalidate>
    <fieldset class="form-group">
        <label class="control-label col-md-2" for="price">Price:</label>
        <div class="col-md-10">
            <input id="price" type="text" class="form-control" ng-model="entry.price" placeholder="Price" title="Price" />
        </div>
    </fieldset>

    <fieldset>
        <button type="submit" class="btn btn-primary pull-right"> Submit Entry <i class="ion-checkmark-round"></i></button>
    </fieldset>                            
</form>

但是在缩小(使用 Grunt 和 Usemin)并从 Dist 文件夹提供缩小后的文件之后,表单输入正确呈现,但提交按钮根本不存在。

dist/scripts/script.*******.js 的相关部分显示按钮 html 仍然存在

a.put('...<form class="form-horizontal" ng-submit="entry.addEntry()" novalidate>
<fieldset class="form-group has-feedback"> <label class="control-label col-md-2" for="price">Price:</label> <div class="col-md-10"> <input id="price" type="text" class="form-control" ng-model="entry.price" placeholder="Price" title="Price"> </div> </fieldset>
<fieldset>\r\n                                <button type="submit" class="btn btn-primary pull-right"> Submit Entry <i class="ion-checkmark-round"></i></button>\r\n                            </fieldset>\r\n                            \r\n                        </form>

显然,Grunt 缩小已将按钮发送到 dist 文件夹,但它只是不渲染,无论是在 chrome 或 firefox 还是从 heroku。

我能指出的唯一奇怪的事情是这些奇怪的空格与一堆换行符和回车一起被插入到构建文件中。

如果这是罪魁祸首,该怎么办?另外,为什么 grunt 文件会在按钮周围插入空格?它还在其他几个领域做到了这一点。但无论如何,手动删除空格和换行符似乎并不能解决问题

在另一种非常相似的形式中,按钮在缩小后也不会呈现。在缩小的脚本文件的那部分中还插入了一些空格。缩小后,应用中的所有其他按钮都可以正确呈现和运行

我的编辑器是 Visual Studio Code

请帮我看看我做错了什么!

【问题讨论】:

    标签: html angularjs gruntjs grunt-usemin


    【解决方案1】:

    我解决了这个问题

    这是其中一个输入字段中的一个小错误。实际上,不是我上面发布的那个。

    我不小心写了一个textarea标签作为自闭合标签,以旧输入标签的方式

    <textarea something something /></textarea>
    

    unminified 这被解释为我想要的那样,所以当然从未检测到错误

    但在缩小过程中它被简化为

    <textarea something something />
    

    它从未正确关闭,因此删除了一些后续块

    所以我想我可以从中概括:

    html解析器可以在缩小之前处理一些错误,但是缩小解析器可能会以不同的方式处理错误,之后可能会出现错误

    所以任何奇怪的压缩后错误都应该导致仔细检查 html 以确保正确的标签格式

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-24
      • 2012-07-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多