Passing data between views in vue.js – best practice

I am fairly new to vue.js.

Wanted to know what was a best practice when sharing data between views.

I am using vuex and vue-router already. Let's say I'm going from a department page and then to an individual employee page.

If I click a link to go to the employee, I've been using 2 approaches:

1.) Save 'currentEmployeeId' in the vuex store, then retrieving that info in the created() method on the employee view. Or - 2.) Retrieving the route param ala this.$route.params.empId in created() on the employee view.

From there, I'll go to the store to get additional data. But what's the preferred way to share this data between views, and is one way more secure than the other?

Thanks in advance.

Read more here:

Content Attribution

This content was originally published by Mike at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: