Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Display Vuex Data Differently in Each Page of Nuxt and Vue.js


    You often use the same data in different ways across pages. This lesson walks you through setting up multiple pages, retrieving the same data, then displaying it for each page's use-case.



    Become a Member to view code

    You must be a Pro Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    orLog In




    To finish up the other pages I'll just copy and paste all of this into the Active view. Now when I hit Save if I navigate to active it should look the exact same and have all the same features. Let's remove some of these features. We'll remove the form. We'll call this Active Todos here, and even get rid of the ability to click on the buttons.

    Now, Active is just a list of active todos. Then if I go back into Home and check off eat, when I go back to active, it's still showing eat. Let's make sure that's filtered out. I can just do this in this computed state here. I'll just say filter out any todo where the todo is complete but not complete, like that.

    Now, in Active it'll only show us the ones that haven't been completed. Home looks like this. Active looks like this. I'll copy and paste everything from Active into Completed. I'll paste that there. Then I can also clean up the methods. I don't need any of these. I don't need the data. I don't need this Import.

    My Active view is really short, with just a template and a list that loops through my todos. I'll copy and paste this into my Completed. Select all and paste. Now Completed will just be the same thing except it only wants to show complete ones.

    Now, if I navigate to Completed, it looks like I accidentally deleted mapState, so let's import that back. mapState from UX and Active will need that as well. Refresh here. Now Completed shows active todos.

    Let's change that to Completed and we can even get rid of the strike-through on this so that now Completed todos are eat, Active todos are code, and back in Home I can add another build something cool. Read a book.

    We'll check this off, navigate to Completed. We'll see eat and "build something cool." I can refresh. We'll have the proper things. Go to Active. Have all the proper things there. Then in my terminal I can even just say now and deploy this application.

    Once that's complete I can just go ahead and open this in a new tab, hit Enter, and now we have this application live online, where I can complete Completed, Active, Home, Delete. Everything works just as expected.