【问题标题】:Laravel AdminLTE template VUE errorLaravel AdminLTE 模板 VUE 错误
【发布时间】:2017-11-12 15:25:51
【问题描述】:

我想在我的页面上添加一个引导模式,并且我在文档的头部包含了jQuery 脚本。这是模态

<!-- Modal -->
<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                Delete {{$title}}?
            </div>
            <div class="modal-body">
                Are you sure you want to delete {{$body}}?
            </div>
            <div class="modal-footer">
                <a class="btn btn-danger btn-ok">Yes</a>
                <button type="button" class="btn btn-default" data-dismiss="modal">No</button>
            </div>
        </div>
    </div>
</div>
<script>
    $('#confirm-delete').on('show.bs.modal', function(e) {
        $(this).find('.btn-ok').attr('href', $(e.relatedTarget).data('href'));
    });
</script>

页面加载时出现错误提示:

[Vue warn]: Error compiling template:
...
...
- Templates should only be responsible for mapping the state to the UI. Avoid placing tags with side-effects in your templates, such as <script>, as they will not be parsed.


(found in <Root>)

而且我不知道出了什么问题,因为我在我的其他项目中也使用了相同的模式并且它可以正常工作。

【问题讨论】:

    标签: php jquery twitter-bootstrap laravel vue.js


    【解决方案1】:

    把模板里的&lt;script&gt;标签全部去掉,放到模板外面。

    在这种情况下,您使用 body 作为模板,并将脚本放入模板(body)中,并确保您的根元素上有一个结束标记。

    【讨论】:

    • 我可以轻松彻底摆脱 Vue 吗?我不希望它编译任何东西
    猜你喜欢
    • 2017-04-20
    • 2023-03-15
    • 2019-02-27
    • 1970-01-01
    • 2020-01-25
    • 2020-11-15
    • 1970-01-01
    • 1970-01-01
    • 2015-10-24
    相关资源
    最近更新 更多