How to pass url parameters to Vuejs

后端 未结 5 2024
感情败类
感情败类 2021-02-13 05:14

I\'m building an app with laravel and VueJs and I was wondering how to pass a url parameter like the user slug or the user id to vuejs in a proper way to be able to use that pa

5条回答
  •  囚心锁ツ
    2021-02-13 05:42

    You can get the url of the link you click and then use this url to do your ajax request.

    methods: {
        load: function(elem, e) {
            e.preventDefault();
            var url = e.target.href;
            this.$http.get(url, function (data, status, request) {
                // update your vue 
            });
        },
    },
    

    And in your template call this method when the user click on a link:

    link
    

提交回复
热议问题