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
@@ -200,13 +200,13 @@ List of 300 VueJS Interview Questions
200
200
|191|[What is the versioning behavior in preset plugins?](#what-is-the-versioning-behavior-in-preset-plugins)|
201
201
|192|[How do you allow plugin prompts?](#how-do-you-allow-plugin-prompts)|
202
202
|193|[What are remote presets?](#what-are-remote-presets)|
203
-
|194|[](#)|
204
-
|195|[](#)|
205
-
|196|[](#)|
206
-
|197|[](#)|
207
-
|198|[](#)|
208
-
|199|[](#)|
209
-
|200|[](#)|
203
+
|194|[Can I use local presets?](#can-i-use-local-presets)|
204
+
|195|[What is the purpose of browserslist option?](#what-is-the-purpose-of-browserslist-option)|
205
+
|196|[How do you find VueJS version using API?](#how-do-you-find-vuejs-version-using-api)|
206
+
|197|[How do you create reactive objects](#how-do-you-create-reactive-objects)|
207
+
|198|[What is the purpose new slot directive?](#what-is-the-purpose-new-slot-directive)|
208
+
|199|[What is the use of compile method?](#what-is-the-use-of-compile-method)|
209
+
|200|[What does nextTick do in VueJS?](#what-does-nexttick-do-in-vuejs)|
210
210
211
211
1.### What is VueJS?
212
212
**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.
@@ -3401,12 +3401,103 @@ List of 300 VueJS Interview Questions
3401
3401
# use preset from GitHub repo
3402
3402
vue create --preset username/repo my-project
3403
3403
```
3404
-
194. ### ?
3405
-
195. ### ?
3406
-
196. ### ?
3407
-
197. ### ?
3408
-
198. ### ?
3409
-
199. ### ?
3410
-
200. ### ?
3404
+
194. ### Can I use local presets?
3405
+
Yes, Vue CLI will load local presets if the value for the --preset option is a relative or absolute file path, or ends with .json. i.e, You can work with local presets directly. These local presets avoids repeatedly pushing the preset to a remote repo to test.
3406
+
```javascript
3407
+
// Directory contains preset.json file
3408
+
vue create --preset ./my-preset my-project
3409
+
(OR)
3410
+
vue create --preset my-preset.json my-project
3411
+
```
3412
+
195. ### What is the purpose of browserslist option?
3413
+
The browserslist option is available in package.json file in order to specify a range of browsers the project is supported. This value is going to be used by babel and autoprefixer to transpile javascript features and applying vendor prefixes.
3414
+
For example, you can declare it as follows,
3415
+
```javascript
3416
+
"browserslist": [
3417
+
"last 1 version",
3418
+
"> 1%",
3419
+
"IE 10"
3420
+
]
3421
+
```
3422
+
196. ### How do you find VueJS version using API?
3423
+
The community plugins and components might need different strategies for different versions. In this case, you can use **Vue.version** which provides installed version of Vue as a string.
3424
+
For example, you can implement different logic based on different versions
3425
+
```javascript
3426
+
let version =Number(Vue.version.split('.')[0])
3427
+
3428
+
if (version ===2) {
3429
+
// Vue v2.x.x
3430
+
} elseif (version ===1) {
3431
+
// Vue v1.x.x
3432
+
} else {
3433
+
// Unsupported versions of Vue
3434
+
}
3435
+
```
3436
+
197. ### How do you create reactive objects?
3437
+
From 2.6 version onwards, you can create reactive objects with Vue.observable() global API.
3438
+
```javascript
3439
+
constreactiveState=Vue.observable({
3440
+
count:0
3441
+
})
3442
+
```
3443
+
These observable objects can be used directly in computed properties and render functions.
3444
+
```javascript
3445
+
constDemo= {
3446
+
render(h) {
3447
+
returnh('button', {
3448
+
on: { click: () => { reactiveState.count++ }}
3449
+
}, `count is: ${state.count}`)
3450
+
}
3451
+
}
3452
+
```
3453
+
198. ### What is the purpose new slot directive?
3454
+
In Vue 2.6 version, the new slot syntax is provided using v-slot directive which aligns syntax with Vue 3.0. This is going to be replacement for old slot syntax.
3455
+
The comparison for old and new slot syntax:
3456
+
```javascript
3457
+
<!-- old -->
3458
+
<user>
3459
+
<template slot="header" slot-scope="{ msg }">
3460
+
text slot: {{ msg }}
3461
+
</template>
3462
+
</user>
3463
+
3464
+
<!--new-->
3465
+
<user>
3466
+
<template v-slot:header="{ msg }">
3467
+
text slot: {{ msg }}
3468
+
</template>
3469
+
</user>
3470
+
```
3471
+
199. ### What is the use of compile method?
3472
+
VueJS provides compile method which is used to compile a template string into a render function. This method is only available in the full build.
3473
+
For example, you can compile template message:
3474
+
```javascript
3475
+
var result =Vue.compile('<div><span>{{ msg }}</span></div>')
3476
+
3477
+
newVue({
3478
+
data: {
3479
+
msg:'Welcome to Vue world'
3480
+
},
3481
+
render:result.render,
3482
+
staticRenderFns:result.staticRenderFns
3483
+
})
3484
+
```
3485
+
200. ### What does nextTick do in VueJS?
3486
+
The nextTick method is just a comfortable way to execute a function after the data has been set, and the DOM has been updated. As an example, the usage is going to be similar to setTimeout:
0 commit comments