question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ReferenceError: Can't find variable: $route

See original GitHub issue

… not so much a bug as a support request I imagine.

I am just getting started with Vue.js. I’m trying to follow the tutorial here: https://scotch.io/tutorials/build-a-single-page-time-tracking-app-with-vue-js-part-ii. It is written for the 1.x version of vue and vue-router, so I have to figure out what’s different as I go along.

I’ve gotten so far that I have a router with paths (‘/home’ and ‘/time-entries’), and components for each of them rendered in <router-view></router-view> in the main App.vue component. When I navigate to ‘/time-entries’, the console shows this error:

ReferenceError: Can't find variable: $route

The TimeEntries.vue component for this path is:


<template>
  <router-link
    class="btn btn-primary"
    v-if="$route.path !== '/time-entries/log-time'"
  >
  Log Time
  </router-link>
</template>

Does anyone have an idea of why $route is not available for binding in my TimeEntries component? Or what it should be changed to?

I realize I’m not giving you much to go on, but since I’m new to this, I’m not sure what other files / output would be relevant. Please let me know what else you’d like to see. I’d appreciate any helpful advice! (Especially: could someone point me in the direction of some debugging techniques/tools when using the vue-cli scaffolding?)

thanks!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jesselawsoncommented, Feb 25, 2018

This is super old, but since I arrived here I would imagine someone else from 2016’s future will arrive here as well.

The key is to use this.$route.whatever, and not just $route.

That is all. Back to 2024 for me.

0reactions
zacenocommented, Oct 16, 2016

Great tip! Thanks again

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't find variable: navigate - Stack Overflow
I am trying to access navigate inside the onPressButton method but it giving an error. Can't find variable: navigate. import React, { Component...
Read more >
ReferenceError: Can't find variable: router - Framework7 Forum
Hi, I'm trying to use this code: router.navigate('/about/', { transition: 'f7-cover' }); But I'm getting this error: ReferenceError: Can't ...
Read more >
Stack Navigator | React Navigation
Stack Navigator provides a way for your app to transition between screens where each new screen is placed on top of a stack....
Read more >
Help with react navigation : r/reactnative - Reddit
Am getting can't find variable navigation error on my code and am not sure how to fix it. My code is quite badly...
Read more >
React Native Navigation: Tutorial with examples
... try restarting your device. Your browser can't play this video. ... import { NativeRouter, Route, Link } from "react-router-native"; ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found