The functionality of Vue's keep-alive feature seems to be malfunctioning within Quasar, as the mounted hook is consistently triggered when using

I am working on a Quasar application where I want to implement page caching using keep-alive in a specific scenario. The scenario is as follows: the user goes from the home page to Page 1, then navigates to Page 2, and finally returns to Page 1 using $router.back() from Page 2. Currently, when the user goes back to Page 1, the mounted() hook is executed again and the page is re-rendered, making an unnecessary API call. My current code implementation is like this:

  <q-page-container class="overflow-auto">
    <keep-alive>
      <router-view :key="$route.fullPath"></router-view>
    </keep-alive>
  </q-page-container>

I have set up the name property in the routes and also on the page itself. I have even tried using: include="Home,Workout" but the issue persists - the mounted hook runs every time and the page gets re-rendered. Additionally, I need the page to stay alive so I can adjust the scroll behavior and bring the user back to where they were before leaving Page 1. Even though I can see that it's remembered (like the console log showing y:883), the page reloads and scrolls to the top again. It may be worth mentioning that I am using router hash mode.

Answer №1

router-view is now recommended to not be directly placed inside keep-alive. Instead, it is advised to utilize slot props in the following manner:

<router-view v-slot="{ Component }">
    <keep-alive>
        <component :is="Component" />
    </keep-alive>
</router-view>

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

What is the syntax for defining parameters in an overloaded arrow function in TypeScript?

Trying to create an async arrow function that can handle a single image object or an array of image objects. I'm new to TypeScript overloading and may be approaching this the wrong way. Here's what I've come up with: type ImageType = { ...

Using Laravel Mix's import functionality to bring in __webpack_require__

Currently utilizing Laravel version 5.8 Building a single page application with VueJs, Facing an issue related to a specific dependency Encountering errors when accessing certain pages https://i.sstatic.net/WdZrZ.png https://i.sstatic.net/05hVI.png Lis ...

filtering an array based on a specific property will result in the original array remaining

Working on filtering an array of objects based on a certain property using the following code snippet: if (payment == Payment.CREDIT_CARD) { this.currenies.filter((currency: Currency) => currency.isFromEurope === true); console.log(this.currencies) ...

What causes the data property to supersede the return false in a jQuery ajax call?

Below is a block of code that I am currently working with: $("#contact_container form, #contact_details form").live( "submit", function(event) { $.ajax({ type: this.method, url: this.action, data: this.s ...

Displaying API errors using JavaScript

As a novice web developer, I recently completed my first project using Vue and Laravel 8. However, when trying to access my API, I encountered an error message: {"message":"The given data was invalid.","errors":{"email":["This email already exists."],"log ...

Utilizing Nextjs version 13 for implementing an API route with the ytdl-core

Recently, I've been experimenting with setting up a basic YouTube downloader using ytdl-core & nextjs. In my code, there's an onClick function that makes an API call. const onClick = async () => { await fetch("/api") .then(async (re ...

How should white space be managed in Bootstrap 4 cards when incorporating responsive column classes - wrap elements inside divs or apply classes directly?

In Bootstrap 4, when applying a responsive column class like "col-sm-8" directly to a "div" with the class "card", whitespace is added between the card border and content. This can be seen in the highlighted yellow area in the image below. https://i.sstat ...

What are some of the methods that can be used with the Facebook API to interact with the Like button

I am working on developing a JavaScript script that will automatically click on all the LIKE buttons for posts loaded on Facebook in the Chrome browser. Input: "" Or any other FB page,Groups,Profiles Step1: I will scroll down to load all the posts S ...

Discovering the server endpoint for the Star Wars SWAPI API: a step-by-step guide

I have been working on integrating a search query into the server-side endpoint, which interacts with swapi - the Star Wars API https://swapi.co/ to display a list of people by their names. Below is the fetch call made to the backend in App.js file using ...

Traversing JSON data in a recursive manner without definite knowledge of its size or nesting levels

Currently, I'm working on a chrome app that utilizes local storage. The backend returns JSON data which I then save locally and encrypt all the items within the JSON. I have multiple sets of JSON with different encryption functions for each set. I at ...

Is there a simpler method to access the source element for an event?

I'm just starting to learn JavaScript and jQuery, and right now I have the following code in my HTML: <a id="tog_table0" href="javascript:toggle_table('#tog_table0', '#hideable_table0');">show</a> After that, I hav ...

How to import a template from a different webpage in AngularJS

I have a situation where I need to include a template from one HTML page into another because they are both lengthy and it's not practical to keep them on the same page. Therefore, I have decided to separate them for better organization. Here is an ov ...

What is the best way to guide the user to a different page with PHP once the preventDefault() function in jQuery has been utilized on a

My approach to form validation involves using jQuery, AJAX, and PHP on my website. I utilize PHP for the actual input validation process as I believe it is more secure and prevents users from manipulating scripts through browser source code inspection. Add ...

What steps should I take to resolve the "StrictMode has found deprecated findDOMNode" error?

Whenever I trigger the button to open the drawer, my console displays the warning message '' findDOMNode is deprecated in StrictMode'' The container for the button component is called Sidenav import Sidenav from './Sidenav'; ...

The functionality of the Jquery mobile panel ceases to work properly when navigating between pages within a multi-page

Within a multi-page template setup in a jQuery mobile application, an issue arises after navigating away from the first page using panel navigation. Upon returning to the first page through another form of navigation, the panel appears "hanged." Upon clos ...

Upon adding an item dynamically, it appears outside of the owl-stage-outer element

I am currently dealing with an unusual issue. I have set up a carousel that loops through using vuejs. <div class="owl-carousel unitslide"> <div v-for="unit in sortedUnits" class="unit" :class="{selected : activeUnit.id === unit.id}" @click="a ...

Is it possible to delete and substitute all content following a specific DIV tag?

Is there a way to utilize JavaScript or jQuery to remove all content following a specific div element and insert new code? The div elements are generated dynamically, and I need to remove everything after the last div that looks similar to: & ...

Creating an Azure function that utilizes an HTTP trigger to handle and process HTTP POST requests containing multipart/form-data

I am currently utilizing Azure function apps with C# (or NodeJS). How can I create an http post request to accomplish the following task? The Http trigger function app needs to send an HTTP request to a different server to retrieve some data. Parse the in ...

What is the best way to pass the double-clicked row as a parameter to a function, when the row is dynamically created in the code?

I am facing an issue with adding rows to an empty table using a button and attaching a dblclick event listener to each row. The challenge arises when I need to execute a function that requires the specific row being double-clicked. In tables already popu ...

Error 404 on Nuxt.js routes when using IISNODE in Internet Information Services

Currently attempting to host a demo of nuxt.js and express.js on IIS with iisnode. Unfortunately, I am encountering 404 errors for the nuxt page routes, while the express API routes are functioning correctly. The setup involves allowing express to manage ...