Setting a variable in a v-tab using Vuetify now only takes 2 easy clicks!

I'm currently utilizing Vuetify and vuejs to develop a tab system with 3 tabs. The tabs are being switched dynamically by binding to the href of a v-tab. Each time I click on a tab, the value of the speed variable is modified. However, I'm encountering an issue where the speed variable seems to lag behind by one click. This means that even after clicking on the expedited tab, the speed variable remains stuck on standard until the next click, at which point it updates to expedited and the tab functions as expected. I've provided my code below and there don't appear to be any errors present..

<template>
  <v-app>
    <v-container fill-height>
      <v-layout row wrap align-center>
        <v-flex xs8 class="mx-auto">
            <h1 class="display-1 mont bold fix-title-height pb-3">Shipping Settings</h1>
            <v-tabs icons-and-text centered color="purple darken-3" dark class="elevation-12">
              <v-tabs-slider color="green lighten-1"></v-tabs-slider>
              <v-tab :href="'#' + speed" @click="setStandard">
                Standard
              </v-tab>
              <v-tab :href="'#' + speed" @click="setExpedited">
                Expedited
              </v-tab>
              <v-tab :href="'#' + speed" @click="setPriority">
                Priority
              </v-tab>

              <v-tab-item id="standard">
                <standard_speed></standard_speed>
              </v-tab-item>

              <v-tab-item id="expedited">
                <v-card flat>
                  <v-card-text>expedited here</v-card-text>
                </v-card>
              </v-tab-item>

              <v-tab-item id="priority">
                <v-card flat>
                  <v-card-text>priority here</v-card-text>
                </v-card>
              </v-tab-item>

            </v-tabs>
         </v-flex> 
     </v-layout>
    </v-container>   
  </v-app>
</template>

<script>
import standard_speed from '../components/standard_speed.vue';

export default {
  data: function() {
    return {
      speed: "standard"
    };
  },
  components: {
    standard_speed
  },
  methods: {
    setStandard() {
      console.log("Is speed getting set? " + this.speed);
      this.speed = "standard";
    },
    setExpedited() {
      this.speed = "expedited"
    },
    setPriority() {
      this.speed = "priority"
    },    
  }
};
</script>

<style>


</style>

Can anyone provide insight into why my speed variable is experiencing a delay in updating upon the initial click?

Answer №1

There is no need to include a href attribute for the v-tab component in Vuetify. This option is not even included in the Vuetify API documentation. A basic example of using v-tabs and v-tab components would be as follows:

<v-tabs
      v-model="active"
      color="cyan"
      dark
      slider-color="yellow"
    >
      <v-tab
        v-for="n in 3"
        :key="n"
        ripple
      >
        Item {{ n }}
      </v-tab>
      <v-tab-item
        v-for="n in 3"
        :key="n"
      >
        <v-card flat>
          <v-card-text>{{ text }}</v-card-text>
        </v-card>
      </v-tab-item>
    </v-tabs>

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

Adding a characteristic to every item in an array of objects

Currently, I am utilizing Node.js along with Mongoose to interact with a MongoDB database and retrieve an array of objects from a specific collection. However, my aim is to add an additional property to each of these retrieved objects. Below, you can see t ...

Only line breaks are permitted in Mustache.js, all other HTML characters are escaped

After a user submits input, I am generating comments and displaying them using Mustache.js. When it comes to rendering the comments, I have found that replacing user-entered line breaks (\n) with <br/> allows them to display as HTML breaks. To ...

Maximize the performance of Express and Swig to boost HTML rendering efficiency

I encountered a significant problem. Here is the breakdown of my application architecture: nginx -> web app (express/nodejs) -> api (jetty/java) -> mysql The performance of the API application is optimized, with response times around 200ms/req ...

Activating the change event in jQuery: A step-by-step guide

Within my ASP.NET page, I have included a UserControl that contains a RadioButtonList. Whenever an item in the RadioButtonList is changed, I need to trigger the following jQuery function: $('#rdlUser').change(function (e) { alert("change fun ...

What causes the "undefined" error in Node.js when using a

Currently, I am utilizing the node-craigslist package for scraping listings from craigslist. However, I have encountered an issue when processing the results. client .search(options, '') .then((listings) => { listings.forEach((listing ...

Is it Possible to Insert Function from a For... in Loop?

Question: How is a function being attached to a variable's memory space without being explicitly assigned? Situation: I have developed a script to eliminate duplicate objects by comparing the values of object keys. However, after initializing the che ...

What is the best approach to resolving the MongoServerError: E11000 duplicate key error?

Index.Js File: const cookieSession = require("cookie-session"); const express = require("express"); const app = express(); const helmet = require("helmet"); const morgan = require("morgan"); const dotenv = require(&q ...

Utilizing LoopBack Storage Service: Leveraging upload/download functions within JavaScript code

Is there a straightforward way to upload and download files using the storageService.upload and storageService.download functions in my JavaScript/Loopback code? I'm trying to achieve something like this: app.post("/sendFile", (req, res) => client ...

Error in Vue Router: required parameter is missing for the specified named route

My unique identifier is successfully being passed to the URL, but I can't figure out why I'm encountering this error. I attempted a method where I added default parameters to my path: '*', however, it didn't work. routes.js { pa ...

Looking for repeating values in inputs excluding this one

In the midst of a medium-sized project, an issue has arisen. I have condensed the core problem into this code snippet. Here's what the code does: $(".6").focusout(function(){ if( $(".6").filter(function(){ return this.value;}).not(this).length>0 ...

click event not triggering custom hook

I have developed a custom hook for fetching data and am struggling to implement it successfully. Below is my custom hook: import { useReducer } from "react"; import axios from "axios"; const dataFetchReducer = (state, action) => { ...

Utilizing JQuery to make Google listings easily findable

Implementing Google Places for a location text box has been successful. However, I am now looking to create a class-based implementation so that I can use it with multiple places effortlessly. Is it possible to achieve this using JQuery? <script type ...

Encountering a ReferenceError stating that the window object is not defined while building a React Leaflet application

In my upcoming nextjs project, I've incorporated react-leaflet. It behaves flawlessly in dev mode. However, upon attempting to build the project, it throws a ReferenceError: window is not defined. Despite setting ssr to false in dynamic, the error per ...

JavaScript on Ruby on Rails stops functioning in js.erb file

I have encountered an issue with pagination using AJAX in a view. Initially, I had two paginations working perfectly fine with their respective AJAX calls. However, when I tried to add a third pagination (following the same method as the previous two), it ...

Next JS throwing internal server error when authenticating with axios

I'm encountering a 500 internal server error when trying to authenticate with Next Auth. I followed the documentation from Next Auth for implementation. import NextAuth from "next-auth"; import CredentialsProvider from "next-auth/provi ...

What is the best way to dynamically disable choices in mat-select depending on the option chosen?

I was recently working on a project that involved using mat-select elements. In this project, I encountered a specific requirement where I needed to achieve the following two tasks: When the 'all' option is selected in either of the mat-select e ...

Safeguard your contact information on the screen

On my classified website, I have concerns about the contact numbers being displayed as plain text in the product details page. This makes them visible to search engines. Is there a way to protect or display phone numbers as images to keep them hidden fro ...

The close button on the jQuery UI Dialog fails to appear when using a local jQuery file

I may sound silly asking this, but I have a simple webpage where I've added a jQuery modal dialog box. Strangely, when I link directly to the jQuery files online (like http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css), everything works ...

Tips for building a dynamic navigation menu using AngularJS

Looking to dynamically generate a navigation menu using an angularjs controller: index.html: <body> <div ng-controller="navi"> <ul> <li ng-repeat="nav in navigations"> <a href="{{nav.path ...

Discover how to retrieve full response data by entering text into a text field using Reactjs

I am encountering an issue while retrieving values from rendered data in a component that has already been displayed on the page. I want to input data into a text field and have it sent to the database, but using the runtime data from that specific field. ...