0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Vue RouterとRails

Posted at

RailsでVue Routerを実装してみました。

  • app/javacript/app.vue
<script>
import { defineComponent } from 'vue'
import RouterVue from './components/Router.vue'

export default defineComponent({
  name: 'App',
  setup() {
      return {
          state: {
              message: "アプリを構築中"
          }
      }
  },
  components: {
      RouterVue
  }
})
</script>
  • app/javacript/components/Router.vue
<template>
  <div>
    <router-link to="/reservations" class="btn btn-primary mx-2">
      予約フォーム
    </router-link>
  </div>
</template>
  • app/javacript/router.js
import { createRouter, createWebHistory } from 'vue-router'
import ReservationForm from './components/reservatiopns/ReservationForm.vue'

const routes = [
  { path: '/reservations', name: 'index', component: ReservationForm },
  // Add more routes as needed
]

const router = createRouter({
  history: createWebHistory(),
  routes,
})

export default router
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?