Is there a way for the list page to retain certain parameters?

As I work on my Vue project, I am facing an issue that needs to be resolved.

https://i.sstatic.net/Emy7o.png

Within my router.js:

{
      path: '/home/aftersale_physicalserver_workpanel/:use_flag/:areapartition_homeshowtext',
      meta: { keepAlive: true },
      icon: 'compose',
      name: 'aftersale_physicalserver_workpanel',
      title: 'work panel',
      component: resolve => {
        require(['./views/main_home/home/components/general_admin_staff_panel/physicalserver/physicalserver_workpanel.vue'], resolve);
      }
    },

In the code snippet above, you can see:

...
<template>
  <lml-page
     ref="lml_page_ref"
     v-if=" origin_data && origin_data.count"
     :data_count="origin_data.count"
     :current.sync="cur_page"
     @change_page_for_parent="server_change_page">
  </lml-page>
</template>
...

<script>
  export default {
  props: {
    ...
    cur_page: 1,
  },
</script>

The value of cur_page indicates the page number. My goal is to append this page number to the URL so that when I navigate back from a detail page, it remembers the correct page.


Objective

My objective is to ensure that the list page retains certain parameters, such as the previous page number and search criteria. However, I am unsure how to achieve this in Vue.js.

For instance, when I move from a searched parameter page to a detailed page and then return using:

<span class="go-left" @click="$router.go(-1)">
   <Icon type="chevron-left"></Icon>
   <span>Go back</span>
</span>

The list page does not display the previously searched data.

Answer №1

In order to manage the state in your application, you have the option to either use local storage or a centralized state management system. Personally, I prefer using Vuex for this purpose. Here is an example of how you can implement it:

onPageChange: function (pageNo) {
        this.$store.dispatch(this.$mts.some.SOMETHING, pageNo);
      },

By following this approach, you will be able to access your store whenever needed and retrieve the page number using get. I recommend checking out the Vuex documentation for guidance on setting up state management effectively.

this.page = this.$store.getters.some.page

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

Is there a way to determine if a browser's network activity is inactive?

Within an angularJS application, a noticeable delay can be experienced between the user and the server (potentially due to limited bandwidth), resulting in a wait time of approximately 2-500ms when loading a new page. I am considering implementing a metho ...

Retrieve and save files under a common directory

I have a specific route called payments/transactions that retrieves all relevant data. I'm interested in finding a way to generate a CSV file without the need to create new routes or add query parameters, so that my route appears as payments/transacti ...

Automated Desk: adjust page through programming

I am currently utilizing Smart Table and I would like to automatically navigate to a specific page once the controller has been created and the table is displayed. After searching on stackoverflow, I came across this code snippet that allows me to achieve ...

Experiencing issues with Panolens.js failing to load images

Currently, I am in the process of setting up a basic 3D image viewer using Panolens.js. Despite following the example provided in the documentation, I am encountering console errors during the loading process. This is my initial attempt at working with equ ...

Using XOAuth2 authentication with Gmail to provide client ID, client secret, and refresh token for sending emails through Node Mail

I have integrated nodemailer with my NodeJS server and successfully set up the following credentials using one of my email addresses: - Client ID - Client Secret - Refresh Token However, I am currently facing an issue due to Google changing their confi ...

CSS changes triggered by JQuery are ineffective

Having trouble modifying the CSS of a class in my HTML file. I've been struggling with this for quite some time and can't figure out what I'm doing wrong. (I've already attempted multiple versions, but nothing seems to work) Here' ...

What steps should be taken to make mocha utilize the HTTP response?

Every time I make an http call, the function it returns causes my comparison to fail because [Function] is never equal to the value I want. Is there a way to make my assert statement consider the true/false flag within it? # test/helloWorld.js const othe ...

Using Selenium webdriver to assign a JSON object to a paragraph element

What is the correct way to insert a JSON object into a p tag inside an iframe? I attempted the following approach but it displayed the text "[object Object]" rather than the actual content of the object... This is my implemented code: var arrJSON = [ ...

Tips on adjusting the font size of headers in a Vuetify v-data-table?

I've been struggling to change the font size of the headers in my v-data-table. No matter what I try, the font doesn't seem to update. I even experimented with the Chrome developer tool and managed to make it work there. However, when I attempt t ...

Code snippet for Selenium to retrieve text/locate visible elements specifically tagged with the class name "one":

I'm struggling with selenium and need to extract text from a visible element that has the class "one". Check out the HTML snippet below: <div id="result-success" class="text-center displayed"> <h3 class="one">Success</h3> <p cla ...

Select multiple options with personalized text using V-select

Can anyone help me with populating a v-select component from Vuetify 1.5 with checkboxes using multiple? The issue arises when I add <template slot='item' slot-scope='{ item }'></template>. It seems that the checkboxes do no ...

Experiencing browser crashes following the incorporation of asynchronous functions into a JavaScript file. Seeking solutions to resolve this

In my recent project, I developed a basic online store application using vanilla javascript and ES6 classes. The shop items are stored in a JSON file which I used to populate the user interface. To implement functions like "addToCart", "quantityChange", a ...

Nightwatch encounters issues during the initialization of the page object

I am currently in the process of testing a Vue application. I have developed 2 simple page objects and created 2 simple spec files to run the end-to-end test. The first test (login) passes without any issues, however, the second test fails with the followi ...

Can you identify the transport protocol that serves as the foundation for XmlHttpRequest?

I'm interested in finding out if it's SOAP, plain HTTP, or something different. I tried looking up XmlHttpRequest on Wikipedia but couldn't find any information about it there. ...

Comparing arrays of objects based on their values rather than their indexes results in equality regardless of position within

I'm currently using the following version specifications: "jasmine-core": "~2.8.0", "jasmine-spec-reporter": "~4.2.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "@types/jasmine": "~2.8.3", Maybe it's a simple quest ...

What is the best way to delete spaces between span elements while preserving the spaces within each individual span tag?

Is there a way to eliminate unexpected spaces that appear between spans? One attempt was made by setting font-size: 0 within the wrapper <div>, which successfully removed spaces not only between <span> tags but also within each <span> ta ...

Is there a way to incorporate an image, logo, and text into a 3D canvas?

https://i.sstatic.net/X7snd.png Recently diving into Three.js, I am faced with a challenge. I am attempting to display a 3D model in the canvas along with a logo and text message. However, when I try to capture the canvas using renderer.domElement.toDataU ...

Ways to ensure that the form data stays consistent and visible to the user continuously

Is there a way to ensure that the user submits the form, stores it in a MYSQL database, and then displays the same submitted data in the form field? <div class="form-group"> <label class="control-label col-sm-2" for="lname">Last Name*</l ...

Discovering the method to access item values within a loop in Vue.js

Issue: I'm currently grappling with how to transfer the value of a selected item to another component Explore the codepen: https://codepen.io/anon/pen/zRXBNY Within the codepen menu, an item is activated by a right click Imagine we have a loop (th ...

Modify HTML button text after successful action

I need help with toggling the content of an HTML button (activate or deactivate) when clicked. I want the button to change from "Activate" to "Deactivate" and vice versa, using AJAX. Here is my code: <button type="button" class="btn btn-success btn-sm" ...