You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+53-7Lines changed: 53 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -185,6 +185,8 @@ List of 300 VueJS Interview Questions
185
185
|176|[What is the default namespace behavior in vuex?](#what-is-the-default-namespace-behavior-in-vuex)|
186
186
|177|[When do you reuse modules?](#when-do-you-reuse-modules)|
187
187
|178|[What are the principles enforced by vuex?](#what-are-the-principles-enforced-by-vuex)|
188
+
|179|[Can I perform mutations directly in strict mode?](#can-i-perform-mutations-directly-in-strict-mode)|
189
+
|180|[How to use model directive with two way computed property?](#how-to-use-model-directive-with-two-way-computed-property)|
188
190
189
191
1.### What is VueJS?
190
192
**Vue.js** is an open-source, progressive Javascript framework for building user interfaces that aim to be incrementally adoptable. The core library of VueJS is focused on the `view layer` only, and is easy to pick up and integrate with other libraries or existing projects.
@@ -3107,11 +3109,11 @@ List of 300 VueJS Interview Questions
3107
3109
}, 1000)
3108
3110
})
3109
3111
},
3110
-
actionTwo ({ dispatch, commit }) {
3111
-
returndispatch('actionA').then(() => {
3112
-
commit('second mutation')
3113
-
})
3114
-
}
3112
+
actionTwo ({ dispatch, commit }) {
3113
+
returndispatch('actionA').then(() => {
3114
+
commit('second mutation')
3115
+
})
3116
+
}
3115
3117
}
3116
3118
```
3117
3119
As per the above example, When you try to dispatch actionTwo it dispatchs actionOne first and then commits respective mutation. You can still simplify with async/await as below,
@@ -3204,6 +3206,50 @@ List of 300 VueJS Interview Questions
3204
3206
1. The Application-level state need to be centralized in the store
3205
3207
2. The state should be mutated by committing mutations only(i.e, for synchronous transactions)
3206
3208
3. The actions should be used for asynchronous transactions
3207
-
179. ### ?
3208
-
180. ### ?
3209
+
179. ### Can I perform mutations directly in strict mode?
3210
+
In strict mode, you can't mutate state directly using `v-model` attribute. If you use v-model it throws an error because mutation is not performed inside an explicit Vuex mutation handler.
3211
+
For example, the below input throws an error due to v-model usage
3212
+
```javascript
3213
+
<input v-model="stateObject.message">
3214
+
```
3215
+
In this case, you need to bind the <input>'s value. It can be resolved using value attribute as below,
0 commit comments