Adding a login form to a Vuetify single page application that is not within a sidebar

Stepping into the world of spa routing, I find myself navigating through Vue.js on the frontend and Laravel on the backend with the help of the Vuetify component framework.

The root of my application lies at {domain}/app. In the backend, the route is defined as:

Route::get('app', function () {
    return view('index');
});

A glimpse into the contents of index.blade.php reveals:

@extends('master')
@section('content')
<v-app id="inspire">
<v-navigation-drawer
v-model="drawer"
fixed
app
>
  <!-- Include other components -->
  <v-content>
      <v-container fluid>
          <router-view></router-view>
      </v-container>
  </v-content>
</v-navigation-drawer>
@endsection

However, the challenge arises when integrating a new page such as the login page. It cannot be placed within the navigation drawer as it is not a child of v-app, but rather an independent v-app. The structure of Login.vue illustrates this predicament:

<v-app id="inspire">
      <v-content>
        <v-container fluid fill-height>
        <!-- Insert login form here -->
        </v-container>
      </v-content>
</v-app>

To address this issue, how can routes be configured in a manner that the login route exists as a standalone v-app instead of being nested within the primary v-app? This question leads me to evaluate the current setup in routes.js:

let routes = [
    { path: '/', component: require('./views/Home') },
    { path: '/login', component: require('./views/auth/Login') },
    { path: '/order', component: require('./views/order/List') },
    //... Additional routes ...
]

Answer №1

Here is a suggested approach

MainApp.vue (root)

<template>
   <main>
      <transition mode="out-in">
        <router-view></router-view>
      </transition>
   </main>
</template>

In app.js set up the layout of #app

import MainLayout from './components/MainApp.vue'

new Vue(
  Vue.util.extend(
     { router, store },   // router.js, store.js (if using modules or Vuex)
     MainLayout
  )  
).$mount('#app')

HomePage.vue (main page)

<template>
   <v-app id="home">

     //...any content like navbars can go here

      <v-content>
        <transition mode="out-in">
           <router-view></router-view>
        </transition>
     </v-content>

   </v-app>
</template>

UserDashboard.vue (with navigation-drawer)

<template>
   <v-app id="dashboard">

     <v-navigation-drawer app>
          ...
     </v-navigation-drawer>

     //...any contents can be added here

     <v-content>
        <transition mode="out-in">
           <router-view></router-view>
        </transition>
     </v-content>

   </v-app>
</template>

routes.js

import HomePage from './components/HomePage'
import Login from './components/Login'
import UserDashboard from './components/UserDashboard'
import Panel from './components/Panel'

export const routes = [
 {
    path: '/',
    component: HomePage,
    children: [
        {
            path: '/login',
            component: Login
        }
    ]
 },
 {
    path: '/user-dashboard',
    component: UserDashboard,
    children: [
        {
            path: '/user-dashboard/panel',
            component: Panel
        }
    ]
 }
]

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Display value of select box remains unchanged even after making an AJAX request

I am currently utilizing react-final-form to showcase all the form fields. However, I am encountering an issue where when I attempt to modify the value of one select box and invoke an AJAX call through the onChange event, even after receiving a response, I ...

encoding the special character "ü" in json_encode as either 'ü' or '&#

I've developed a function that extracts the title from a given URL and returns it in JSON format. The function is invoked by an AJAX call. Everything works smoothly, but when a title contains characters like ü or any related ones, it returns null. Wh ...

Changing a string into a dictionary using Javascript

Here is the data I have: d0 = "{\"a\":\"324jk324\",\"b\":\"42793bi42\",\"c\":\"894h42hi\"}" d = JSON.parse(d0) \\ g ...

utilizing various ajax functions

I'm having trouble using additional functions with the "complete:" option in JQuery ajax after the "selectOptionSort" function. Can anyone help me figure out what's wrong? $('#tipos').change(function(){ $("#marcas ...

When the document loads, remember to implement a click event on the list item

With the following list: <ul id="test" > <li>list item 1</li> <li>list item 2</li> <li>list item 3</li> <li>list item 4</li> <li>list item 5</li> </ul> I am looking to trig ...

Navigational Buttons for Forms in Bootstrap Tabs

I am currently working on splitting a form across multiple Bootstrap 3.x tabs. However, I am encountering issues with the functionality of the previous and next buttons. Only the first next button seems to be working correctly, and there are instances wh ...

Identify user input with Python Selenium for keyboard and mouse interactions

As a frequent user of Selenium Browser for my everyday browsing needs, I am looking to implement some code that will be triggered when certain keys are pressed on any page. Initially, I considered loading JavaScript onto each page to track key and mouse in ...

JavaScript does not function properly with dynamically loaded content

Trying to load the page content using the JQuery load() method. See below for the code snippet: $(window).ready(function() { $('#content').load('views/login.html'); }); .mdl-layout { align-items: center; justify-content: center ...

Having trouble viewing the npm version on Ubuntu due to the error message: "Module 'semver' not found"

After reinstalling ubuntu on my computer, I proceeded to install node, react, and npm. However, when I attempted to run an old project, I encountered the same error message that I had faced previously. Even checking the version of npm resulted in an error. ...

Using Angular Ngrx to Retrieve and Showcase a Selection of Choices from a Java API

When accessing the Java API at localhost://company/products/123/fetchOptions, you can expect a response similar to the following: { "Increase": true, "Decrease" : true, "Like" : true, "Dislike" : true, "Old" : false, "Others" : true } Using Angula ...

"Utilizing MongoDB's aggregate function to filter data by specific

I'm attempting to calculate the average temperature and humidity from my JSON response at 15-minute intervals using the MongoDB Aggregate framework. However, I'm encountering a SyntaxError: invalid property id @(shell):2:0 This is the code I am ...

An issue has arisen with AngularJS and Twitter Bootstrap, displaying an error message stating that the function element.focus

I recently implemented the angularjs twitter bootstrap datepicker and everything seemed to be working smoothly. However, I encountered an error when trying to click on the text box for the popup datepicker. This issue has left me puzzled as I am still new ...

What is the best way to show a tooltip alongside highlighted text?

How can I display a tooltip (using qTip) next to selected text? The code below captures the selected text in the console, but the tooltip is not displayed. <div class='test'>Actual text will be much longer...Test Test Test Test Test Test T ...

In AngularJS, one way to mark an input field as ng-invalid is by following these steps

I need to validate an input field for credit card numbers. The input should only be considered valid once it reaches a minimum length of 13 characters. To allow users to enter spaces in the field, I have implemented a JavaScript function to remove these s ...

"Hey, do you need a see-through background for your

Currently, I am implementing the JS library found at . Unfortunately, I am struggling to make the background transparent or any other color. It appears that the issue lies in the fact that the tab styles are being overridden by the JS library whenever the ...

Running a repeated script

I recently discovered a fantastic script called Typer that creates a typewriter effect. However, I noticed that it does not have a built-in method to loop the animation once it reaches the end. Does anyone have any suggestions on how to achieve this? t ...

The functionality of Jquery Ajax is limited to a single use

I'm having an issue with a page that is supposed to reload the data within a div using jQuery, but it only updates once. Here's a snippet of my code: <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0 ...

Exploring table iteration in Angular 7

I am looking to create a table with one property per cell, but I want each row to contain 4 cells before moving on to the next row... This is what I want: <table> <tr> <td> <mat-checkbox>1</mat-checkbox& ...

Problem with AJAX file directory

Okay, so I've encountered an issue with my AJAX request. It works perfectly when I place the php file in the same folder as the html file containing the AJAX code, like this: var URL = "question1.php?q1=" + radioValue; However, I want to organize my ...

Transforming an array of strings into a Name/Value object using JavaScript

Recently, I encountered a Web Service that sends an array of strings to the client. My goal is to transform this array into an object where each string has a name for future reference. Let's start with: var result = ["test", "hello", "goodbye"]; An ...