Computed properties without setter with VueX

Reactivity in Depth

One of Vue’s most distinct feature is the unobtrusive reactivity system. Models are just plain JavaScript objects but when you modify them, the view updates. It makes state management simple and intuitive, but it’s also important to understand how it works to avoid some common gotchas

When using computed get/set properties we always expect to provide set function to accept new added object base on user.

But did you KNOW?

Computed get/set properties works even if there’s no set function?

NO its not working!! It will give an ERROR: Computed property “users” was assigned to but it has no setter.

How it will works:

(Note: you can do it in any javascript playground, but this sample run using jsfiddle)


1. Import scripts.

<script src=”"></script>

<script src=”"></script>

<script src=”"></script>

2. Create div and assign id to app.


  1. Create new Vue instance and assign it to app.

2. Create store from Vuex instance.

  • The undefined store in instruction 1 is now resolved.
  • Define users as array in state.
  • Assign state users to getters.
  • In actions create function getUser to request list of users.
  • Actions commit mutations.

3. Add component using Vue instance (make sure name from html and component are the same).

Now your HTML and JS is complete, you can try adding new name by clicking the plus (+) button.

It will display simple input and just enter name.

You will see that the new added name in the user list without getting any warnings/errors.


How Changes Are Tracked:

Looking for a JOB? Signup @ jobbhy and be notified!

Want to post a JOB as employer? Contact and be one us!




Axios Refresh Token (A simple and straightforward request interceptor.)

ASP.NET Core & VueJS Starter kit

Looking for a asynchronous modular micro-framework Reser

by RhaldKhein

Software Engineer @ Appman Co., Ltd.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store