Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
1
Help us understand the problem. What is going on with this article?
@hashito

vue-routerでURL 引数を受け取る方法

More than 1 year has passed since last update.

はじめに

少し詰まってしまったので備忘録

やりたいこと

URLがhttp://xxx.xxx.xxx.xxx?test=v{test:'v'}を受け取りたい。

やり方

        <script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.js"></script>
        <script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
        <script>
            // routerを初期化
            var router = new VueRouter({
                mode: 'history',
                routes: []
                });
            var app = new Vue({
                router,// router を追加
                el: '#app',
                data:{},
                created: function () {
                    // routerから読み込み
                    console.log(this.$route.query)
                }
            })
        </script>

詰まったところ

  • VueRouterを初期化し作らなければならない
  • VueRouterのインスタンスをVueインスタンスに渡さなければならない
1
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
hashito
わたしです。 主に個人的なメモです。

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
1
Help us understand the problem. What is going on with this article?