首页 > 解决方案 > Laravel Material Design 主题奇怪的​​行为

问题描述

最近我安装了Laravel Material Design主题。我设法很好地设置了所有内容,并且一切正常,直到我添加了一些vue.js templates. 当我导入我的app.js文件时,我的模板被加载到那里,主题的一些功能刚刚停止工作,我不知道为什么。这是我的app.js文件:

require('./bootstrap');

window.Vue = require('vue');

Vue.component('users-component', require('./components/UsersComponent').default);
Vue.component('blogs-component', require('./components/BlogsComponent').default);
Vue.component('news-component', require('./components/NewsComponent').default);
Vue.component('paginator', require('./components/Paginator.vue').default);

const app = new Vue({
    el: '#vue',
});

因此,我编译了文件,并将其导入到app.blade.php布局的底部:

....
<script src="{{ mix('/js/app.js') }}" defer></script>

当我加载我的页面时,我vue.js templates的工作正常。问题是,主题导航刚刚停止工作,我无法单击导航列表:

在此处输入图像描述

我开始调查,在浏览器控制台中,我看到以下错误:

在此处输入图像描述

当我app.js从布局中删除文件时,导航再次开始工作,我在控制台中看不到任何错误,但当然,我vue.js templates的工作不正常。这是我的布局中导入脚本的完整列表:

<!--   Core JS Files   -->
<script src="{{ asset('material') }}/js/core/jquery.min.js"></script>
<script src="{{ asset('material') }}/js/core/popper.min.js"></script>
<script src="{{ asset('material') }}/js/core/bootstrap-material-design.min.js"></script>
<script src="{{ asset('material') }}/js/plugins/perfect-scrollbar.jquery.min.js"></script>
<!-- Plugin for the momentJs  -->
<script src="{{ asset('material') }}/js/plugins/moment.min.js"></script>
<!--  Plugin for Sweet Alert -->
<script src="{{ asset('material') }}/js/plugins/sweetalert2.js"></script>
<!-- Forms Validations Plugin -->
<script src="{{ asset('material') }}/js/plugins/jquery.validate.min.js"></script>
<!-- Plugin for the Wizard, full documentation here: https://github.com/VinceG/twitter-bootstrap-wizard -->
<script src="{{ asset('material') }}/js/plugins/jquery.bootstrap-wizard.js"></script>
<!--    Plugin for Select, full documentation here: http://silviomoreto.github.io/bootstrap-select -->
<script src="{{ asset('material') }}/js/plugins/bootstrap-selectpicker.js"></script>
<!--  Plugin for the DateTimePicker, full documentation here: https://eonasdan.github.io/bootstrap-datetimepicker/ -->
<script src="{{ asset('material') }}/js/plugins/bootstrap-datetimepicker.min.js"></script>
<!--  DataTables.net Plugin, full documentation here: https://datatables.net/  -->
<script src="{{ asset('material') }}/js/plugins/jquery.dataTables.min.js"></script>
<!--    Plugin for Tags, full documentation here: https://github.com/bootstrap-tagsinput/bootstrap-tagsinputs  -->
<script src="{{ asset('material') }}/js/plugins/bootstrap-tagsinput.js"></script>
<!-- Plugin for Fileupload, full documentation here: http://www.jasny.net/bootstrap/javascript/#fileinput -->
<script src="{{ asset('material') }}/js/plugins/jasny-bootstrap.min.js"></script>
<!--  Full Calendar Plugin, full documentation here: https://github.com/fullcalendar/fullcalendar    -->
<script src="{{ asset('material') }}/js/plugins/fullcalendar.min.js"></script>
<!-- Vector Map plugin, full documentation here: http://jvectormap.com/documentation/ -->
<script src="{{ asset('material') }}/js/plugins/jquery-jvectormap.js"></script>
<!--  Plugin for the Sliders, full documentation here: http://refreshless.com/nouislider/ -->
<script src="{{ asset('material') }}/js/plugins/nouislider.min.js"></script>
<!-- Include a polyfill for ES6 Promises (optional) for IE11, UC Browser and Android browser support SweetAlert -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/2.4.1/core.js"></script>
<!-- Library for dynamically adding elements -->
<script src="{{ asset('material') }}/js/plugins/arrive.min.js"></script>
<!-- Chartist JS -->
<script src="{{ asset('material') }}/js/plugins/chartist.min.js"></script>
<!--  Notifications Plugin    -->
<script src="{{ asset('material') }}/js/plugins/bootstrap-notify.js"></script>
<!-- Control Center for Material Dashboard: parallax effects, scripts for the example pages etc -->
<script src="{{ asset('material') }}/js/material-dashboard.js?v=2.1.1" type="text/javascript"></script>
<script src="{{ mix('/js/app.js') }}" defer></script>
@stack('js')

@if(isset($scripts))
    @foreach($scripts as $key => $value)
        <script src="{{ asset($value)}}"></script>
    @endforeach
@endif

这里似乎有什么问题。任何帮助表示赞赏。

更新:

这是 bootsrtap.js:

window._ = require('lodash');

/**
 * We'll load jQuery and the Bootstrap jQuery plugin which provides support
 * for JavaScript based Bootstrap features such as modals and tabs. This
 * code may be modified to fit the specific needs of your application.
 */

try {
    window.Popper = require('popper.js').default;
    window.$ = window.jQuery = require('jquery');

    require('bootstrap');
} catch (e) {}

/**
 * We'll load the axios HTTP library which allows us to easily issue requests
 * to our Laravel back-end. This library automatically handles sending the
 * CSRF token as a header based on the value of the "XSRF" token cookie.
 */

window.axios = require('axios');

window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

标签: javascriptlaravelmaterial-design

解决方案


推荐阅读