Please help me with my homework.
I make a system with vueJS (vueCLI, vue-router).
I want to get the id from the url, but an error occurs in my writing. How can I solve it?
Error
Uncaught ReferenceError: $route is not defined
router.js
export default new Router({
mode: "history",
base: process.env.BASE_URL,
routes: [
{
path: "/s/:id",
name: "Result",
component: Result
},
Result.vue
<script>
export default {
methods: {
window: (onload = function() {
const id = this.$route.params.id;
})
}
};
</script>