0

我在 laravel 上使用 vue js,我的资源/js 文件夹中有两个不同的文件 app.js 和 app-filter.js

我想要的是在特定页面上调用 app-filter.js 但始终为每个页面调用 app js:

在我的 app-filter.js 我有

const filter = Vue.component('filter-project', require('./components/filter-project.vue').default);
 
const appfilterproject = new Vue({
    el: '#app-filter-project',
    components: {
        'filter-project': filter
    }
});

在我的 app.js 我

const app= new Vue({ el: '#app', components: { 'other-component': othercomponent } });

所以在我的页面中,当我调用 app-filter 时,我有这些导入

<script src="{{ asset('front/js/app-filter-project.js') }}"></script>
<script src="{{ asset('front/js/app.js') }}" defer></script>

顺序是各自的

在我的页面中我打电话

<div id="app">
    <other-component></other-component>
</div>

<div id="app-filter-project">
    <filter-project></filter-project>
</div>

这两个组件显示在页面中,但在我的 devtools 上它只显示我的other-component

并且过滤器项目组件上的任何事件都不起作用,如果我从导入中删除 app.js,一切正常

4

0 回答 0