What are the disadvantages of changing store data without commit Mutation in vuex?

the official website of vuex suggests changing the data in store through commit mutation, but it is not convenient in the actual project, because there are too many states to change, and it is troublesome to write many methods to commit, so I added the path path to the state data in store through js

.

clipboard.png

then bind the path to the tag that needs to change the state, obtain the path, when you need to change the state, and change the data state in the store through eval ("this.$store.getters.PhysicsData" + path + ".ifCollection =" + true); ). Now the effect has been achieved, but I am always in a hurry. I would like to ask all the great gods, is there any drawback in modifying store in this way?

Feb.28,2021

the mutations of Veux is a very important point, that is, all the logical methods of dealing with data are put in mutations, so that the data and view are separated.

you can achieve your goal if you do that, but it is not recommended in terms of robustness, readability, and maintainability. If your colleague or the next person who fills the hole doesn't understand what you're thinking, do you have to swear everywhere with a muddled face?


< H2 > Mutation < / H2 >
the only way to change the state in Vuex's store is to submit the mutation. Mutation in Vuex is very similar to events: each mutation has a event type (type) of a string and a callback function (handler) .
< H2 > strict mode < / H2 >
in strict mode, an error is thrown whenever a state change occurs and is not caused by the mutation function. This ensures that all state changes can be tracked by the debugger.

first of all, what you are doing must be wrong, and what you are doing will only make it more complicated.
you say that there are too many states that need to be changed. It is troublesome to write multiple mutation to commit . Do you have any misunderstandings about mutation

?

you can do this to achieve the same effect:

  

I just looked at it. It can also be tracked by vue debugging tools, but the readability is not high, and the code is not as comfortable as you. I will consider whether it can be changed to this way in the project. Thank you

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf9294-537f0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf9294-537f0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?