@kayyyy Try this: this.$route.params.slug
Vuejs get url param
Half the day i am trying to get the url param in vuejs :)
module.exports = {
template: require('./show.html'),
ready: function() {
this.fetchMessages();
},
methods: {
fetchMessages: function(params) {
this.$http.get('http://domain.dev/api/library/' + params.slug , function(course) {
this.$set('course', course);
console.log(params);
});
}
}
};
But i am getting the error, that slug is not defined.
If i use { {$route.params.slug} } in my view, it returns the slug. ( http://vuejs.github.io/vue-router/route.html )
The API returns the slug: http://domain.dev/api/library/slug
So for example i have the url http://domain.dev/dashboard#!/library/shopware-grundlagen
If i hardcode the API Url ( http://domain.dev/api/library/shopware-grundlagen ) it works and i am getting all my details about the item, but of course it must be dynamicly :)
Could someone help me to get this thing working?
Please or to participate in this conversation.