简体   繁体   English

Inertiajs - 在本地切换到另一个页面

[英]Inertiajs - Switch to another page locally

I would like to know how to switch between different pages on the client side only, without inertia.visit().我想知道如何仅在客户端的不同页面之间切换,而无需惯性访问()。

I am using Laravel and Inertiajs.我正在使用 Laravel 和 Inertiajs。

I understand that props must be specified from the laravel side in order to move to another page.我了解必须从 laravel 一侧指定道具才能移动到另一页。

Is there any way to switch pages without communication between client and server?有没有办法在客户端和服务器之间没有通信的情况下切换页面?

I want to switch pages only on the client side with the URL, not by switching components within the same page.我只想在客户端使用 URL 切换页面,而不是通过在同一页面内切换组件。

Not sure if you are asking for this, but InertiaJS has an alternative for manual visits - the InertiaJS Link :不确定您是否要求这样做,但 InertiaJS 有手动访问的替代方法 - InertiaJS Link

<template>
  <Link href="/myPage" v-text="`Click me`" />
</template>

<script setup>
  import { Link } from '@inertiajs/inertia-vue3'
</script>

Logically, anyways you'll have to register a route in routes/web.php , else you'll get a 404:从逻辑上讲,无论如何你都必须在routes/web.php中注册一个路由,否则你会得到一个 404:

Route::get('/myPage', function () {
  return inertia('MyPage');
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM