带有Laravel的Vue惯性组件似乎加载了两次

带有Laravel的Vue惯性组件似乎加载了两次,laravel,vue.js,inertiajs,Laravel,Vue.js,Inertiajs,对于新创建的Laravel With Inertia和Vue项目,我有一个错误,它在我的Vue组件中运行了两次代码 对于一个简单的测试演示,我有一个 <template> <div> TEST </div> </template> <script> export default { name: "Test", mounted() { console.log('test')

对于新创建的Laravel With Inertia和Vue项目,我有一个错误,它在我的Vue组件中运行了两次代码

对于一个简单的测试演示,我有一个

<template>
<div>
    TEST
</div>
</template>

<script>
export default {
    name: "Test",
    mounted() {
        console.log('test')
    }
}
</script>

<style scoped>

</style>

在控制器中:

    public function test(): Response
    {
        return Inertia::render('Test');
    }
当我转到路由/测试时,它会在我的控制台中安装两次“测试”。在调用API之类的更高级组件中,也会调用它们两次

我怀疑我的项目可能是错误的,在或,但无法找出它

我按照向导的指示进行设置

我的源代码如下:


编辑:在我加载的第一个组件中,它似乎只回显两次。如果我在该组件中链接到另一个组件,并转到该组件,它不会加载两次。

我发现通过修改资源目录中的app.js文件可以解决这个问题,因此:

从“Vue”导入Vue
从'@inertiajs/inertia vue'导入{App as InertiaApp,plugin as InertiaPlugin}
Vue.use(InertiaPlugin)
新Vue({
渲染:(h)=>
h(惰性气体{
道具:{
initialPage:JSON.parse(app.dataset.page),
resolveComponent:(name)=>require(`./Pages/${name}`)。默认值,
},
}),
})$mount(app)
    public function test(): Response
    {
        return Inertia::render('Test');
    }