score:2
like all the other answers, there are so many things wrong with this code.
firstly, there is a routes.js file, but it's not being used.
i've created a sandbox version of your code https://codesandbox.io/s/z22rx97z24 to show you a working version of the router/app.
what's changed?
firstly, you should export an instance of the vue router in the routes.js not just define a const. this is the recommended way of routing in vue.
import vue from "vue";
import router from "vue-router";
import app from "./app";
import login from "./components/auth/login";
import logout from "./components/auth/logout";
import register from "./components/auth/register";
vue.use(router);
export default new router({
routes: [
{
path: "/customers",
name: "customers",
component: app,
meta: {
requiresauth: true
}
},
{
path: "/login",
name: "login",
component: login,
meta: {
requiresvisitor: true
}
},
{
path: "/register",
name: "register",
component: register,
meta: {
requiresvisitor: true
}
},
{
path: "/logout",
name: "logout",
component: logout
}
]
});
secondly, you import that instance into app.js and assign into the router property of the vue instance.
import vue from "vue";
import vuerouter from "vue-router";
import router from "./routes";
vue.use(vuerouter);
const app = new vue({
el: "#app",
router: router
});
you keep components out of your app.js where possible. this allows you to do things like on-demand resource loading inside your router.js etc.
score:0
you seem to have mixed up some code in your app.js
file.
specifically, your problem is here...
{ path: '/login', component: login },
you don't have a login
symbol defined anywhere. you're also defining some global components which i'm not sure you want to do.
what i think you want is to remove all this...
vue.component('login', require('./components/auth/login.vue').default);
const router = new vuerouter({
routes: [
{ path: '/login', component: login },
{ path: '/register', component: register }
]
})
and replace it with
import { routes } from './routes'
const router = new vuerouter({ routes })
i'm also a little suspicious of
require('./bootstrap');
but you haven't said what bootstrap
is so i'll leave that with you to figure out.
score:0
import routes from './routes.js'
const router = new vuerouter({routes})
to your actual error. yes you imported login in your routes.js file, but at the error shows you, it isn't defined in app.js. you need to import things in every file you want to use it in.
Source: stackoverflow.com
Related Query
- Laravel Vuejs Error: Uncaught ReferenceError: Login is not defined
- Vuejs3 + laravel 8 working find locally but in prod vuejs files throwing syntax error and view not render Uncaught SyntaxError: 59
- VueJS 2 Uncaught ReferenceError: _ is not defined with debounce
- Uncaught ReferenceError: moment is not defined while using moment in laravel with vue js
- Starting out in laravel with vue.js and getting "Property or method is not defined on the instance but referenced during render." error
- Laravel 7.x Uncaught ReferenceError: $ is not defined
- Importing exif-js library Uncaught ReferenceError: EXIF is not defined error
- Error 'require' is not defined while trying to fetch my local json file in vuejs
- Uncaught ReferenceError: route is not defined in Laravel 8
- vuejs dynamic component throw error for v-bind:is, error is Property or method ... is not defined on the instance but referenced during render
- Generating bip39 mnemonic in VueJS, getting error Uncaught ReferenceError: global is not defined
- Uncaught ReferenceError: Home is not defined - Laravel Vue.js
- Uncaught ReferenceError: jQuery is not defined VueJS Parcel
- Laravel normal login with vuejs using axios returns error Request failed with status code 422
- Error in mounted hook: "ReferenceError: posts is not defined in Vuejs
- Property not defined error But it is defined Vue js Laravel
- Property or method "contact" is not defined on the instance but referenced during render Vuejs Laravel
- Laravel + SPA VueJs not giving error for unknown component
- Page is not Inertia rendered after login using vuejs and laravel
- Error : Uncaught ReferenceError: Vue is not defined
- Laravel 5.8 Vue is not defined error when building comment system with Vue.js
- vuejs - Redirect from login/register to home if already loggedin, Redirect from other pages to login if not loggedin in vue-router
- Laravel 5.4 Vue.JS Failed to mount component: template or render function not defined
- VueJS - Unit testing with vue-test-utils gives error - TypeError: _vm.$t is not a function
- Uncaught ReferenceError: Vue is not defined when put vue setting in Index.html
- Laravel is not defined
- Vue Uncaught ReferenceError: process is not defined
- Error when trying to call a constant to a view: the method is not defined
- Uncaught ReferenceError: $ is not defined (VueJS)
- testing vuejs and typescript with jest causes an error "property 'yyy' does not exist on type 'combinedvueinstance'
More Query from same tag
- Vue v-if not working even though condition is met (Font Awesome icon not updating)
- Problems with the integration of Vue 3 and Firestore
- Laravel / Vue - App.js difference between import and require
- vue prop display columns with different sizes wrapped in container
- How do I replicate v-models :value with :value?
- Complete logic decoupling with Vuex
- I'm getting the error in vue.js - Unexpected side effect in "filteredTeamsData" computed property
- set property and retrieve HTML as string from Vue component
- Execute custom functions one after another - Callback logic in Vue.js
- vue.js router active link with url query
- sidebar not collapsing inside vue.js #app element (sb-admin-2)
- vee-validate@4.x - how to manually validate field
- VueJS Filter Array Based on Input
- How to attach a Vuetify v-menu to its parent element in a scrollable list?
- Laravel: Dynamically pass data to Vue Component from Blade Template
- Embedded Youtube video reloads inside component, rendered with v-for, when moving array items
- Accessing vue-axios inside Vuex module actions
- How to run Vue cli with Webpack on live server?
- Unexpected token while access an env variable
- Is that possible to change swipe.js svg arrow images?
- vue.js: How to specify which child component to use?
- Interpolated fill for SVG triangle
- JWT Authorization with Axios and Vue.js (Header)
- [Vue warn]: $attrs is readonly. [Vue warn]: $listeners is readonly
- Why transliteration in not working when I am selection the second input box?
- Stencil EventEmitter don't emit data to Vue instance
- How to use EXDATE in Full Calendar via object option
- vuetify v-select in v-for loop: selected option appears in all iterations of the v-select
- v-list-item-title text color not changing when active in v-navigation-drawer
- Vue-router beforeEach stuck in infinite loop when using next()