Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

87
Views
Rename Vue mapState state

In my computed, I have two "loading" states that I want to track. Is there a way to add an alias to the other state with this syntax?

  computed: {
    ...mapState('barcodes', ['barcodes', 'loading', 'pagination']),
    ...mapState('users', ['user', 'loading']), // add an alias for this "loading"
  }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

mapState has supported an object way, something like: (Specific alias for only 1 field)

computed: {
  ...mapState('barcodes', {
    barcodesLoading: state => state.loading,
  })
}

Or by namespace: (If you want to wrap all user state into the userData namespace)

computed: {
  ...mapState({
      barcodeData: 'barcodes',
      userData: 'users'
  })
}

on Template:

<div>{{barcodeData.loading}}</div>

There is another thread for your reference:

vuex namespaced mapState with multiple modules

about 4 years ago · Juan Pablo Isaza Report

0

I'm not absolutely sure, because I can't check it out right now. But AFAIK you should just try this:

computed: {
    ...mapState('barcodes', {barcodes:'barcodes', alias1:'loading', pagination:'pagination'}),
    ...mapState('users', {user:'user', alias2:'loading'}), // add an alias for this "loading"
  }

I.e. use object instead of array.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!