{"id":26776,"date":"2022-02-15T07:28:35","date_gmt":"2022-02-15T07:28:35","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=26776"},"modified":"2022-04-13T16:55:34","modified_gmt":"2022-04-13T16:55:34","slug":"top-50-questions-and-answers-for-vue-js","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/top-50-questions-and-answers-for-vue-js\/","title":{"rendered":"<strong>Top 50 questions and answers for vue.js<\/strong>"},"content":{"rendered":"\n<p>The Vue (pronounced \/vju\u02d0\/, like view) is a liberal framework for building user borders. Dissimilar other huge frameworks, Vue is designed from the ground up to be incrementally adoptable. The core library is absorbed on the view layer only, and is easy to pick up and mix with other libraries or existing projects. On the other hand, Vue is also perfectly accomplished of powering urbane Single-Page Applications when used in combination with modern tooling and supporting libraries.<\/p>\n\n\n\n<p><strong>Interview Question &amp; Answers:-<\/strong><\/p>\n\n\n\n<p><strong>1. What is Vue.js?<\/strong><\/p>\n\n\n\n<p><strong>Answer:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"581\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/what-is-vue-js-1030x584-1-1024x581.jpg\" alt=\"\" class=\"wp-image-26785\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/what-is-vue-js-1030x584-1-1024x581.jpg 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/what-is-vue-js-1030x584-1-300x170.jpg 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/what-is-vue-js-1030x584-1-768x435.jpg 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/what-is-vue-js-1030x584-1.jpg 1030w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Vue js is progressive javascript script used to create dynamic user interfaces.Vue js is very easy to learn.In order to work with Vue js you just need to add few dynamic features to a website.You don\u2019t need to install any thing to use Vue js just need add Vue js library in your project.<\/p>\n\n\n\n<p><strong>&nbsp;2. How to create an instance of Vue.js?<\/strong><\/p>\n\n\n\n<p><strong>Answer:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"662\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/Vue-instance-lifecycle-Page-1-1024x662.png\" alt=\"\" class=\"wp-image-26786\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/Vue-instance-lifecycle-Page-1-1024x662.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/Vue-instance-lifecycle-Page-1-300x194.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/Vue-instance-lifecycle-Page-1-768x496.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/Vue-instance-lifecycle-Page-1-1536x992.png 1536w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/Vue-instance-lifecycle-Page-1-2048x1323.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Every Vue application starts by creating a new Vue instance with the Vue function:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">var<\/span> vm = <span class=\"hljs-keyword\">new<\/span> Vue({\r\n  <span class=\"hljs-comment\">\/\/ options<\/span>\r\n})\r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>3. What are Components in Vue.js?<\/strong><\/p>\n\n\n\n<p><strong>Answer:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"668\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/vuejs_code_3-1024x668.png\" alt=\"\" class=\"wp-image-26787\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/vuejs_code_3-1024x668.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/vuejs_code_3-300x196.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/vuejs_code_3-768x501.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/vuejs_code_3.png 1126w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Components are one of most powerful features of Vue js.In Vue components are custom elements that help extend basic HTML elements to encapsulate reusable code.<\/p>\n\n\n\n<p>Following is the way to register a Vue component inside another component:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-tag\">export<\/span> <span class=\"hljs-selector-tag\">default<\/span> {\r\n  <span class=\"hljs-attribute\">el<\/span>: <span class=\"hljs-string\">'#your-element'<\/span>\r\n  components: {\r\n      <span class=\"hljs-string\">'your-component'<\/span>\r\n  }\r\n}\r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>4. What are filters in Vue.js?<\/strong><\/p>\n\n\n\n<p><strong>Answer:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"538\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/1_x8NzrnRLNmIeSEa9SbgFLg-1024x538.png\" alt=\"\" class=\"wp-image-26788\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/1_x8NzrnRLNmIeSEa9SbgFLg-1024x538.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/1_x8NzrnRLNmIeSEa9SbgFLg-300x158.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/1_x8NzrnRLNmIeSEa9SbgFLg-768x403.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/1_x8NzrnRLNmIeSEa9SbgFLg.png 1200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In Vue js filters are used to transform the output that are going to rendered on browser.<\/p>\n\n\n\n<p>A Vue.js filter is essentially a function that takes a value, processes it, and then returns the processed value. In the markup it is denoted by a single pipe (|) and can be followed by one or more arguments:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">element<\/span> <span class=\"hljs-attr\">directive<\/span>=<span class=\"hljs-string\">\"expression | filterId \\&#91;args...\\]\"<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">element<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>5. What are Directives in Vue.js, List some of them you used?<\/strong><\/p>\n\n\n\n<p><strong>Answer:<\/strong><\/p>\n\n\n\n<p>The concept of directive in Vue js is drastically simpler than that in Angular. Vue.js directives provides a way to extend HTML with new attributes and tags. Vue.js has a set of built-in directives which offers extended functionality to your applications.You can also write your custom directives in Vue.js .<\/p>\n\n\n\n<p>Below are list of commonly used directives in Vue.js<\/p>\n\n\n\n<p>v-show<\/p>\n\n\n\n<p>v-if<\/p>\n\n\n\n<p>v-model<\/p>\n\n\n\n<p>v-else<\/p>\n\n\n\n<p><strong>v-on<\/strong><\/p>\n\n\n\n<p><strong>6. How can I fetch query parameters in Vue.js?<\/strong><\/p>\n\n\n\n<p><strong>Answer:<\/strong><\/p>\n\n\n\n<p>You have access to a $route object from your components, that expose what we need.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-comment\">\/\/from your component<\/span>\r\n<span class=\"hljs-built_in\">console<\/span>.log(<span class=\"hljs-keyword\">this<\/span>.$route.query.test)\r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>7. Explain the basic logical Vue.js app organisation<\/strong><\/p>\n\n\n\n<p><strong>Answer:<\/strong><\/p>\n\n\n\n<p>A Vue.js application consists of a root Vue instance created with new Vue, optionally organized into a tree of nested, reusable components. For example, a todo app\u2019s component tree might look like this:<\/p>\n\n\n\n<p>Root Instance<\/p>\n\n\n\n<p>\u2514\u2500 TodoList<\/p>\n\n\n\n<p>&nbsp;&nbsp; \u251c\u2500 TodoItem<\/p>\n\n\n\n<p>&nbsp;&nbsp; \u2502&nbsp; \u251c\u2500 DeleteTodoButton<\/p>\n\n\n\n<p>&nbsp;&nbsp; \u2502&nbsp; \u2514\u2500 EditTodoButton<\/p>\n\n\n\n<p>&nbsp;&nbsp; \u2514\u2500 TodoListFooter<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u251c\u2500 ClearTodosButton<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u2514\u2500 TodoListStatistics<\/p>\n\n\n\n<p><strong>All Vue components are also Vue instances.<\/strong><\/p>\n\n\n\n<p><strong>8. Explain the differences between one-way data flow and two-way data binding?<\/strong><\/p>\n\n\n\n<p><strong>Answer:<\/strong><\/p>\n\n\n\n<p>In one-way data flow the view(UI) part of application does not updates automatically when data Model is change we need to write some custom code to make it updated every time a data model is changed. In Vue js v-bind is used for one-way data flow or binding.<\/p>\n\n\n\n<p>In two-way data binding the view(UI) part of application automatically updates when data Model is changed. In Vue.js v-model directive is used for two way data binding.<\/p>\n\n\n\n<p><strong>9. List some features of Vue.js<\/strong><\/p>\n\n\n\n<p><strong>Answer:<\/strong><\/p>\n\n\n\n<p>Vue js comes with following features<\/p>\n\n\n\n<p>Templates<\/p>\n\n\n\n<p>Reactivity<\/p>\n\n\n\n<p>Components<\/p>\n\n\n\n<p>Transitions<\/p>\n\n\n\n<p>Routing<\/p>\n\n\n\n<p><strong>10. How to create Two-Way Bindings in Vue.js?<\/strong><\/p>\n\n\n\n<p><strong>Answer:<\/strong><\/p>\n\n\n\n<p>v-model directive is used to create Two-Way Bindings in Vue js.In Two-Way Bindings data or model is bind with DOM and Dom is binded back to model.<\/p>\n\n\n\n<p>In below example you can see how Two-Way Bindings is implemented.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\">\"app\"<\/span>&gt;<\/span>\r\n  {{message}}\r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input<\/span> <span class=\"hljs-attr\">v-model<\/span>=<span class=\"hljs-string\">\"message\"<\/span>&gt;<\/span>\r\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\r\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">script<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\">\"text\/javascript\"<\/span>&gt;<\/span><span class=\"actionscript\">\r\n  <span class=\"hljs-keyword\">var<\/span> message = <span class=\"hljs-string\">'Vue.js is rad'<\/span>;\r\n  <span class=\"hljs-keyword\">new<\/span> Vue({ el: <span class=\"hljs-string\">'#app'<\/span>, data: { message } });\r\n<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">script<\/span>&gt;<\/span>\r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>11. What are the Advantages\/Disadvantages of Vuejs?<\/strong><\/p>\n\n\n\n<p><strong>Answer:<\/strong><\/p>\n\n\n\n<p>Vue.js Advantages<\/p>\n\n\n\n<p>Easy for applications and interfaces development<\/p>\n\n\n\n<p>Support Two-way communication as like AngularJs<\/p>\n\n\n\n<p>Ability to control the states<\/p>\n\n\n\n<p>Natural thought process<\/p>\n\n\n\n<p>Vue.js Disadvantages<\/p>\n\n\n\n<p>Limited scope<\/p>\n\n\n\n<p>Single creator<\/p>\n\n\n\n<p>Small developer community<\/p>\n\n\n\n<p><strong>12. Can I pass parameters in computer properties in Vue.js?<\/strong><\/p>\n\n\n\n<p><strong>Answer:<\/strong><\/p>\n\n\n\n<p>You can use a method or computed function.<\/p>\n\n\n\n<p>The method way:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span>&gt;<\/span>{{ fullName('Hi') }}<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span>\r\nmethods: {\r\nfullName(salut) {\r\nreturn <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token interpolation\"<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token interpolation-punctuation cBase\"<\/span>&gt;<\/span>${<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span>salut<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token interpolation-punctuation cBase\"<\/span>&gt;<\/span>}<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token cString\"<\/span>&gt;<\/span> <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token interpolation\"<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token interpolation-punctuation cBase\"<\/span>&gt;<\/span>${<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token cVar\"<\/span>&gt;<\/span>this<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token cBase\"<\/span>&gt;<\/span>.<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span>firstName<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token interpolation-punctuation cBase\"<\/span>&gt;<\/span>}<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token cString\"<\/span>&gt;<\/span> <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token interpolation\"<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token interpolation-punctuation cBase\"<\/span>&gt;<\/span>${<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token cVar\"<\/span>&gt;<\/span>this<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token cBase\"<\/span>&gt;<\/span>.<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span>lastName<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token interpolation-punctuation cBase\"<\/span>&gt;<\/span>}<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token template-punctuation cString\"<\/span>&gt;<\/span>\r\n}\r\n}\r\n\r\nComputed property with a parameter way:\r\n\r\ncomputed: {\r\nfullName() {\r\nreturn salut =&gt; <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token interpolation\"<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token interpolation-punctuation cBase\"<\/span>&gt;<\/span>${<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span>salut<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token interpolation-punctuation cBase\"<\/span>&gt;<\/span>}<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token cString\"<\/span>&gt;<\/span> <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token interpolation\"<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token interpolation-punctuation cBase\"<\/span>&gt;<\/span>${<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token cVar\"<\/span>&gt;<\/span>this<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token cBase\"<\/span>&gt;<\/span>.<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span>firstName<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token interpolation-punctuation cBase\"<\/span>&gt;<\/span>}<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token cString\"<\/span>&gt;<\/span> \t\t <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token interpolation\"<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token interpolation-punctuation cBase\"<\/span>&gt;<\/span>${<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token cVar\"<\/span>&gt;<\/span>this<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token cBase\"<\/span>&gt;<\/span>.<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span>lastName<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token interpolation-punctuation cBase\"<\/span>&gt;<\/span>}<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"token template-punctuation cString\"<\/span>&gt;<\/span>\r\n}\r\n}\r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>13. What are components props?<\/strong><\/p>\n\n\n\n<p><strong>Answer:<\/strong><\/p>\n\n\n\n<p>Every component instance has its own isolated scope. This means you cannot (and should not) directly reference parent data in a child component\u2019s template. Data can be passed down to child components using props. Props are custom attributes you can register on a component. When a value is passed to a prop attribute, it becomes a property on that component instance.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">Vue.component(<span class=\"hljs-string\">'blog-post'<\/span>, {\r\n<span class=\"hljs-comment\">\/\/ camelCase in JavaScript<\/span>\r\n<span class=\"hljs-attr\">props<\/span>: &#91;<span class=\"hljs-string\">'postTitle'<\/span>],\r\n<span class=\"hljs-attr\">template<\/span>: <span class=\"hljs-string\">'&lt;h3&gt;{{ postTitle }}&lt;\/h3&gt;'<\/span>\r\n})\r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>14. How to deploy Vue.js app?<\/strong><\/p>\n\n\n\n<p><strong>Answer:<\/strong><\/p>\n\n\n\n<p>If you&#8217;ve created your project like this:<\/p>\n\n\n\n<p>vue init webpack myproject<\/p>\n\n\n\n<p>Now you can run<\/p>\n\n\n\n<p>npm run build<\/p>\n\n\n\n<p>Then copy index.html and \/dist\/ folder into your website root directory. Done.<\/p>\n\n\n\n<p><strong>15. How to use local storage with Vue.js?<\/strong><\/p>\n\n\n\n<p><strong>Answer:<\/strong><\/p>\n\n\n\n<p>You can just do following:<\/p>\n\n\n\n<p>localStorage.setItem(&#8216;YourItem&#8217;, response.data)<\/p>\n\n\n\n<p>localStorage.getItem(&#8216;YourItem&#8217;)<\/p>\n\n\n\n<p>localStorage.removeItem(&#8216;YourItem&#8217;)<\/p>\n\n\n\n<p><strong>16. Describe the Vuex?<\/strong><\/p>\n\n\n\n<p>Vuex acts as a centralized store for all the components in an application and ensures that the state can be mutated in a predictable way. It&#8217;s a State Management Pattern plus Library for the applications developed in Vue.js.<\/p>\n\n\n\n<p><strong>18. Explain the single file component.<\/strong><\/p>\n\n\n\n<p>Single File components or SFCs are like any other component except that they are self-contained in their own files. SFCs come with the following advantages.<\/p>\n\n\n\n<p>Global Definitions &#8211; means all SFCs are registered globally so they have unique names.<\/p>\n\n\n\n<p>Strong Templates &#8211; you can write the template code easily in SFCs instead of a single template property like in other components.<\/p>\n\n\n\n<p>CSS Support &#8211; SFCs provide support to add CSS style to the component itself.<\/p>\n\n\n\n<p>Preprocessors Support &#8211; can easily use preprocessors like babel, SAAS etc in SFCs.<\/p>\n\n\n\n<p><strong>19. What is Reactivity in Vue.js?<\/strong><\/p>\n\n\n\n<p>Reactivity &#8211; Whenever you make any changes in data value then it triggers page update to reflect data changes. Vue data property, computed property are reactive. Services in Vue.js are not reactive. For more you can visit Reactivity in Vue.js<\/p>\n\n\n\n<p><strong>20. Explain the Vue.js lifecycle hooks.<\/strong><\/p>\n\n\n\n<p>Every Vue instance passes through certain functions called lifecycle hooks. There are 8 lifecycle hooks for each vue.js instance.<\/p>\n\n\n\n<p>Before Create &#8211; First lifecycle hook that&#8217;s called immediately after a vue instance has been initialized.<\/p>\n\n\n\n<p>Created &#8211; It&#8217;s called just after the &#8216;Before create&#8217; hook but the vue instance has set initial properties, data etc.<\/p>\n\n\n\n<p>Before mount &#8211; It&#8217;s called just before the instance is mounted on DOM. At this moment the template has been compiled.<\/p>\n\n\n\n<p>Mounted &#8211; It&#8217;s called once the template is ready with data and functional.<\/p>\n\n\n\n<p>Before update &#8211; It&#8217;s called when any changes are made to data that requires DOM to be updated.<\/p>\n\n\n\n<p>Updated &#8211; It&#8217;s called just after DOM has updated.<\/p>\n\n\n\n<p>Before destroy It&#8217;s a place where you can perform resource clean up before destroying the vue instance.<\/p>\n\n\n\n<p>destroyed &#8211; It&#8217;s get called when all vue instances have been destroyed. It will be triggered when run the destroy method on an object in code.<\/p>\n\n\n\n<p><strong>21. What is the Key in Vue.js?<\/strong><\/p>\n\n\n\n<p>Key is a special attribute in Vue that is used as a hint for the virtual DOM algorithm of Vue to differentiate the VNodes when defining a new node list against an old list.<\/p>\n\n\n\n<p>If the &#8216;key&#8217; attribute is not used then Vue uses an algorithm that minimizes element movement and tries to reuse the elements of the same type. But with &#8216;key&#8217; attribute elements will be reordered and the elements without key are destroyed. It&#8217;s similar to $index in AngularJS. It&#8217;s mostly used with the &#8216;v-for&#8217; directive.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">ul<\/span>&gt;<\/span>\r\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">li<\/span> <span class=\"hljs-attr\">v-for<\/span>=<span class=\"hljs-string\">\"item in items\"<\/span> <span class=\"hljs-attr\">:key<\/span>=<span class=\"hljs-string\">\"item.id\"<\/span>&gt;<\/span>...<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">li<\/span>&gt;<\/span>\r\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">ul<\/span>&gt;<\/span>\r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>22. Explain the difference between v-show and v-if.<\/strong><\/p>\n\n\n\n<p>v-show and v-if both are used to show or hide the elements. But there are some differences.<\/p>\n\n\n\n<p>v-if directive is used to render a block conditionally. It has lazy behavior meaning if the initial condition is false then it will not render the block until the condition becomes true. v-if completely destroy and recreate the elements during condition change.<\/p>\n\n\n\n<p>It has less initial render cost but high toggle cost so when your condition is not changing frequently at runtime then use v-if directive.<\/p>\n\n\n\n<p>v-show directive is also used to render a block conditionally. v-show always renders the element. It just sets the CSS display property instead of destroying the element or block from DOM.<\/p>\n\n\n\n<p>It has high cost of initial rendering but less cost of toggle, so when you need frequent toggle then use v-show directive.<\/p>\n\n\n\n<p><strong>23. What is $root in Vue.js?<\/strong><\/p>\n\n\n\n<p>$root property is used to access the root instance (new Vue()) in every subcomponent of this instance. All subcomponents can access this root instance and can use it as a global storage.<\/p>\n\n\n\n<p>\/\/ foo will be available globally<\/p>\n\n\n\n<p>this.$root.foo = 2<\/p>\n\n\n\n<p><strong>24. Explain the usage of $parent.<\/strong><\/p>\n\n\n\n<p>$parent is used to access the parent component instance in the child component. It makes the application harder to test and debug and you can not find out where mutation comes from. Similar to $parent Vue also provides a $child that gives a child component instance.<\/p>\n\n\n\n<p><strong>25. Describe the ref in Vue.js.<\/strong><\/p>\n\n\n\n<p>Vue.js provides the concept of props and events to communicate from parent to child and vice versa. Sometimes you need to directly access child components in JavaScript. To achieve this behavior you can use ref attribute to assign a reference ID to the child component as below.<\/p>\n\n\n\n<p>&lt;base-input ref=&#8221;usernameInput&#8221;&gt;&lt;\/base-input&gt;<\/p>\n\n\n\n<p>Now you can access the &#8216;base-input&#8217; instance in the component where you have defined &#8216;ref&#8217;.<\/p>\n\n\n\n<p>this.$refs.usernameInput<\/p>\n\n\n\n<p><strong>26) What are the array detection mutation methods in Vue.js?<\/strong><\/p>\n\n\n\n<p>As the name suggests, the array detection mutation methods in Vue.js are used to modify the original array. Following is a list of array mutation methods which trigger view updates:<\/p>\n\n\n\n<p>push()<\/p>\n\n\n\n<p>pop()<\/p>\n\n\n\n<p>shift()<\/p>\n\n\n\n<p>unshift()<\/p>\n\n\n\n<p>splice()<\/p>\n\n\n\n<p>sort()<\/p>\n\n\n\n<p>reverse()<\/p>\n\n\n\n<p>When you perform any of the above mutation methods on the list, then it triggers view update.<\/p>\n\n\n\n<p><strong>27) What are the array detection non-mutation methods in Vue.js?<\/strong><\/p>\n\n\n\n<p>The array detection non-mutation methods in Vue.js are the methods that do not mutate the original array but always return a new array.<\/p>\n\n\n\n<p>Following is a list of the non-mutation methods:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">filter()\r\nconcat()\r\nslice()\r\nFor example, let's take a todo list where it replaces the old array with new one based on status filter:\r\n\r\nvmvm.todos = vm.todos.filter(function (todo) {  \r\n  return todo.status.match(\/Completed\/)  \r\n})  \r\n<\/code><\/span><\/pre>\n\n\n<p><strong>28) What are the different event modifiers Vue.js provides?<\/strong><\/p>\n\n\n\n<p>Normally, JavaScript provides event.preventDefault() or event.stopPropagation() inside event handlers. We can use Vue.js methods, but these methods are meant for data logic instead of dealing with DOM events.<\/p>\n\n\n\n<p>Vue.js provides the following event modifiers for v-on and these modifiers are directive postfixes denoted by a dot symbol.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\">.stop\r\n.prevent\r\n.capture\r\n.self\r\n.once\r\n.passive\r\nSee the following example of stop modifier:\r\n\r\n<span class=\"hljs-comment\">&lt;!-- the click event's propagation will be stopped --&gt;<\/span>  \r\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">a<\/span> <span class=\"hljs-attr\">v-on:click.stop<\/span>=<span class=\"hljs-string\">\"methodCall\"<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">a<\/span>&gt;<\/span>  \r\nExample of chain modifiers as follows:\r\n<span class=\"hljs-comment\">&lt;!-- modifiers can be chained --&gt;<\/span>  \r\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">a<\/span> <span class=\"hljs-attr\">v-on:click.stop.prevent<\/span>=<span class=\"hljs-string\">\"doThat\"<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">a<\/span>&gt;<\/span>  \r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>29) Give an example to demonstrate how can you use event handlers?<\/strong><\/p>\n\n\n\n<p>Event handlers are used in Vue.js are similar to plain JavaScript. The method calls also support the special $event variable.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">&lt;button v-on:click=<span class=\"hljs-string\">\"show('Welcome to VueJS world', $event)\"<\/span>&gt;  \r\n  Submit  \r\n&lt;\/button&gt;  \r\nmethods: {  \r\n  show: <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-params\">(message, event)<\/span> <\/span>{  \r\n    <span class=\"hljs-comment\">\/\/ now we have access to the native event  <\/span>\r\n    <span class=\"hljs-keyword\">if<\/span> (event) event.preventDefault()  \r\n    console.log(message);  \r\n  }  \r\n}   \r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>30) Give an example to demonstrate how do you define custom key modifier aliases in Vue.js?<\/strong><\/p>\n\n\n\n<p>We can define custom key modifier aliases via the global config.keyCodes. Following are some guidelines for the properties:<\/p>\n\n\n\n<p>We can&#8217;t use camelCase. Instead, we should use a kebab-case with double quotation marks.<\/p>\n\n\n\n<p>We can define multiple values in an array format.<\/p>\n\n\n\n<p>See the example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">Vue.config.keyCodes = {  \r\n  f1: <span class=\"hljs-number\">112<\/span>,  \r\n  <span class=\"hljs-string\">\"media-play-pause\"<\/span>: <span class=\"hljs-number\">179<\/span>,  \r\n  down: &#91;<span class=\"hljs-number\">40<\/span>, <span class=\"hljs-number\">87<\/span>]  \r\n}  \r\nNote: The <span class=\"hljs-keyword\">use<\/span> <span class=\"hljs-title\">of<\/span> <span class=\"hljs-title\">keyCode<\/span> <span class=\"hljs-title\">events<\/span> <span class=\"hljs-title\">is<\/span> <span class=\"hljs-title\">deprecated<\/span>, <span class=\"hljs-title\">and<\/span> <span class=\"hljs-title\">the<\/span> <span class=\"hljs-title\">new<\/span> <span class=\"hljs-title\">browsers<\/span> <span class=\"hljs-title\">don<\/span>'<span class=\"hljs-title\">t<\/span> <span class=\"hljs-title\">support<\/span> <span class=\"hljs-title\">it<\/span>.\r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>31) What are the different supported System Modifier Keys in Vue.js?<\/strong><\/p>\n\n\n\n<p>Vue.js supports the following modifiers to trigger mouse or keyboard event listeners when we press the corresponding keys. The list of supported System Modifier Keys is:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\">.ctrl\r\n.alt\r\n.shift\r\n.meta\r\nSee the following example of a control modifier with the click event.\r\nExample:\r\n<span class=\"hljs-comment\">&lt;!-- Ctrl + Click --&gt;<\/span>  \r\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> @<span class=\"hljs-attr\">click.ctrl<\/span>=<span class=\"hljs-string\">\"doAction\"<\/span>&gt;<\/span>Do some action here<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>  \r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>32) What is the requirement of local registration in Vue.js?<\/strong><\/p>\n\n\n\n<p>In Vue.js, local registration is required when the global registration seems not ideal. For example, suppose you are using a build system like Webpack and globally registering all components. In that case, even if we stop using a component, it could still be included in your final build. This unnecessarily increases the amount of JavaScript your users have to download. In these cases, it is better to define your components as plain JavaScript objects as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">var<\/span> ComponentA = {<span class=\"hljs-comment\">\/*.......*\/<\/span>}   \r\n<span class=\"hljs-keyword\">var<\/span> ComponentB = {<span class=\"hljs-comment\">\/*.......*\/<\/span>}   \r\n<span class=\"hljs-keyword\">var<\/span> ComponentC = {<span class=\"hljs-comment\">\/*.......*\/<\/span>}  \r\nAfter that define the components you would like to use <span class=\"hljs-keyword\">in<\/span> a components option <span class=\"hljs-keyword\">as<\/span> follows:\r\n\r\n<span class=\"hljs-keyword\">new<\/span> Vue({  \r\n<span class=\"hljs-attr\">el<\/span>: <span class=\"hljs-string\">'#app'<\/span>,  \r\n<span class=\"hljs-attr\">components<\/span>: {  \r\n<span class=\"hljs-string\">'component-a'<\/span>: ComponentA,  \r\n<span class=\"hljs-string\">'component-b'<\/span>: ComponentA  \r\n}  \r\n})  \r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>33) What are the different supported Mouse Button Modifiers in Vue.js?<\/strong><\/p>\n\n\n\n<p>Vue.js supports the following mouse button modifiers:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">.left\r\n.right\r\n.middle\r\n<span class=\"hljs-attr\">Example<\/span>:\r\n\r\nThe usage <span class=\"hljs-keyword\">of<\/span> .right modifier <span class=\"hljs-keyword\">as<\/span> follows:\r\n\r\n<span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">button<\/span>   \r\n  <span class=\"hljs-attr\">v-if<\/span>=<span class=\"hljs-string\">\"button === 'right'\"<\/span>  \r\n  <span class=\"hljs-attr\">v-on:mousedown.right<\/span>=<span class=\"hljs-string\">\"increment\"<\/span>  \r\n  <span class=\"hljs-attr\">v-on:mousedown.left<\/span>=<span class=\"hljs-string\">\"decrement\"<\/span>  \r\n\/&gt;<\/span><\/span>  \r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>34) What are the supported modifiers on the v-model directive in Vue.js?<\/strong><\/p>\n\n\n\n<p><strong>Following are the three modifiers supported for the v-model directive in Vue.js:<\/strong><\/p>\n\n\n\n<p>lazy: By default, the v-model directive syncs the input with the data after each input event. We can add the lazy modifier to instead sync after change events.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-15\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-comment\">&lt;!-- synced after \"change\" instead of \"input\" --&gt;<\/span>  \r\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input<\/span> <span class=\"hljs-attr\">v-model.lazy<\/span>=<span class=\"hljs-string\">\"msg\"<\/span> &gt;<\/span>   \r\nnumber: The number modifier is used to our v-model when we want user input to be automatically typecast as a number. With the type=\"number\", the value of HTML input elements always returns a string. That's why this typecast modifier is required.\r\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input<\/span> <span class=\"hljs-attr\">v-model.number<\/span>=<span class=\"hljs-string\">\"age\"<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\">\"number\"<\/span>&gt;<\/span>  \r\ntrim: We should add the trim modifier to our v-model when we want whitespace from user input to be trimmed automatically.\r\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input<\/span> <span class=\"hljs-attr\">v-model.trim<\/span>=<span class=\"hljs-string\">\"msg\"<\/span>&gt;<\/span>  \r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-15\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>35) When the components need a single root element?<\/strong><\/p>\n\n\n\n<p>In Vue.js 2.x version, every component must have a single root element when template has more than one element. In this case, you need to wrap the elements with a parent element.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-16\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">template<\/span>&gt;<\/span>  \r\n   <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"todo-item\"<\/span>&gt;<\/span>  \r\n       <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h2<\/span>&gt;<\/span>{{ title }}<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h2<\/span>&gt;<\/span>  \r\n       <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">v-html<\/span>=<span class=\"hljs-string\">\"content\"<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>  \r\n   <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>  \r\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">template<\/span>&gt;<\/span>  \r\nOtherwise, it will show an error, saying that \"Component template should contain exactly one root element,\"\r\nThe Vue.js 3.x version facilitates that the components now can have multiple root nodes. This way of adding multiple root nodes is called as fragments.\r\n\r\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">template<\/span>&gt;<\/span>  \r\n     <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h2<\/span>&gt;<\/span>{{ title }}<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h2<\/span>&gt;<\/span>  \r\n     <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">v-html<\/span>=<span class=\"hljs-string\">\"content\"<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>  \r\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">template<\/span>&gt;<\/span>  \r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-16\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>36) What do you understand by global registration in components in Vue.js?<\/strong><\/p>\n\n\n\n<p>The global registration in components in Vue.js facilitates us to use it in the template of any root Vue instance (new Vue) created after registration.<\/p>\n\n\n\n<p>In the global registration, the components created using Vue.component as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-17\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">Vue.component(<span class=\"hljs-string\">'my-component-name'<\/span>, {  \r\n  <span class=\"hljs-comment\">\/\/ ... options ...  <\/span>\r\n})  \r\nWe can take multiple components which are globally registered <span class=\"hljs-keyword\">in<\/span> the vue instance,\r\nVue.component(<span class=\"hljs-string\">'component-a'<\/span>, { <span class=\"hljs-comment\">\/* ... *\/<\/span> })  \r\nVue.component(<span class=\"hljs-string\">'component-b'<\/span>, { <span class=\"hljs-comment\">\/* ... *\/<\/span> })  \r\nVue.component(<span class=\"hljs-string\">'component-c'<\/span>, { <span class=\"hljs-comment\">\/* ... *\/<\/span> })  \r\n<span class=\"hljs-keyword\">new<\/span> Vue({ <span class=\"hljs-attr\">el<\/span>: <span class=\"hljs-string\">'#app'<\/span> })  \r\nThe above components can be used <span class=\"hljs-keyword\">in<\/span> the vue instance <span class=\"hljs-keyword\">as<\/span> follows:\r\n\r\n<span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\">\"app\"<\/span>&gt;<\/span>  \r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">component-a<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">component-a<\/span>&gt;<\/span>  \r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">component-b<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">component-b<\/span>&gt;<\/span>  \r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">component-c<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">component-c<\/span>&gt;<\/span>  \r\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span><\/span>  \r\nNote: The components can be used <span class=\"hljs-keyword\">in<\/span> subcomponents <span class=\"hljs-keyword\">as<\/span> well.\r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-17\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>37) What is the purpose of using v-for directive in Vue.js?<\/strong><\/p>\n\n\n\n<p>In Vue.js, the v-for directive is used because it allows us to loop through items in an array or object. By using this directive, we can iterate on each element in the array or object.<\/p>\n\n\n\n<p>Example of v-for directive usage in Array:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-18\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">ul<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\">\"list\"<\/span>&gt;<\/span>  \r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">li<\/span> <span class=\"hljs-attr\">v-for<\/span>=<span class=\"hljs-string\">\"(item, index) in items\"<\/span>&gt;<\/span>  \r\n    {{ index }} - {{ item.message }}  \r\n  <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">li<\/span>&gt;<\/span>  \r\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">ul<\/span>&gt;<\/span>  \r\nvar vm = new Vue({  \r\n  el: '#list',  \r\n  data: {  \r\n    items: &#91;  \r\n      { message: 'Alex' },  \r\n      { message: 'Muler' }  \r\n    ]  \r\n  }  \r\n})  \r\nWe can also use the delimiter instead of in, similar to JavaScript iterators.\r\nExample of v-for directive usage in Object:\r\n\r\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\">\"object\"<\/span>&gt;<\/span>  \r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">v-for<\/span>=<span class=\"hljs-string\">\"(value, key, index) of user\"<\/span>&gt;<\/span>  \r\n    {{ index }}. {{ key }}: {{ value }}  \r\n  <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>  \r\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>  \r\nvar vm = new Vue({  \r\n  el: '#object',  \r\n  data: {  \r\n    user: {  \r\n      firstName: 'Alex',  \r\n      lastName: 'Muller',  \r\n      age: 30  \r\n    }  \r\n  }  \r\n})  \r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-18\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>38) Give an example to demonstrate how do you reuse elements with key attribute?<\/strong><\/p>\n\n\n\n<p>Vue.js always facilitates us to render elements as efficiently as possible. So, it is possible to reuse the elements instead of building them from scratch. But this can create problems in few scenarios. For example, if you try to render the same input element in both v-if and v-else blocks then it holds the previous value as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-19\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">template<\/span> <span class=\"hljs-attr\">v-if<\/span>=<span class=\"hljs-string\">\"loginType === 'Admin'\"<\/span>&gt;<\/span>  \r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">label<\/span>&gt;<\/span>Admin<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">label<\/span>&gt;<\/span>  \r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input<\/span> <span class=\"hljs-attr\">placeholder<\/span>=<span class=\"hljs-string\">\"Enter your ID\"<\/span>&gt;<\/span>  \r\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">template<\/span>&gt;<\/span>  \r\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">template<\/span> <span class=\"hljs-attr\">v-else<\/span>&gt;<\/span>  \r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">label<\/span>&gt;<\/span>Guest<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">label<\/span>&gt;<\/span>  \r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input<\/span> <span class=\"hljs-attr\">placeholder<\/span>=<span class=\"hljs-string\">\"Enter your name\"<\/span>&gt;<\/span>  \r\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">template<\/span>&gt;<\/span>  \r\nIn the above case, we should not reuse it. It is better to make both input elements as separate by applying key attribute as follows:\r\n\r\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">template<\/span> <span class=\"hljs-attr\">v-if<\/span>=<span class=\"hljs-string\">\"loginType === 'Admin'\"<\/span>&gt;<\/span>  \r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">label<\/span>&gt;<\/span>Admin<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">label<\/span>&gt;<\/span>  \r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input<\/span> <span class=\"hljs-attr\">placeholder<\/span>=<span class=\"hljs-string\">\"Enter your ID\"<\/span> <span class=\"hljs-attr\">key<\/span>=<span class=\"hljs-string\">\"admin-id\"<\/span>&gt;<\/span>  \r\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">template<\/span>&gt;<\/span>  \r\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">template<\/span> <span class=\"hljs-attr\">v-else<\/span>&gt;<\/span>  \r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">label<\/span>&gt;<\/span>Guest<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">label<\/span>&gt;<\/span>  \r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input<\/span> <span class=\"hljs-attr\">placeholder<\/span>=<span class=\"hljs-string\">\"Enter your name\"<\/span> <span class=\"hljs-attr\">key<\/span>=<span class=\"hljs-string\">\"user-name\"<\/span>&gt;<\/span>  \r\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">template<\/span>&gt;<\/span>  \r\nIn the above example, both inputs are independent and do not impact each other.\r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-19\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>39) Why is it recommended to use a key attribute for directive?<\/strong><\/p>\n\n\n\n<p>It is recommended to use a key attribute for a directive to track each node&#8217;s identity and thus reuse and reorder existing elements. We have to provide a unique key attribute for each item with in v-for iteration. An ideal value for the key would be the unique id of each item. Example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-20\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">v-for<\/span>=<span class=\"hljs-string\">\"item in items\"<\/span> <span class=\"hljs-attr\">:key<\/span>=<span class=\"hljs-string\">\"item.id\"<\/span>&gt;<\/span>  \r\n  {{item.name}}  \r\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>  \r\nThat's why it is always recommended to provide a key with v-for whenever possible unless the iterated DOM content is simple.\r\n\r\nNote: We should use string or numeric values instead of non-primitive values like objects and arrays.\r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-20\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>40) What do you understand by the array detection non-mutation methods?<\/strong><\/p>\n\n\n\n<p>The methods that do not mutate the original array but always return a new array are known as non-mutation methods.<\/p>\n\n\n\n<p>Following is a list of the non-mutation methods:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">filter() method\r\nconcat() method\r\nslice() method\r\nLet's take an example to understand it better. We have a todo list replacing the old array with a new one based on the status filter.\r\nExample:\r\nvmvm.todos = vm.todos.filter(function (todo) {  \r\n  return todo.status.match(\/Completed\/)  \r\n})  \r\nThis approach would not re-render the entire list due to Vue.js implementation.\r\n<\/code><\/span><\/pre>\n\n\n<p><strong>41) How can you redirect to another page in Vue.js?<\/strong><\/p>\n\n\n\n<p>In Vue.js, if you are using vue-router, you should use router.go(path) to navigate to any particular route. You can access the router from within a component using this.$router. router.go() changed in Vue.js 2.0. You can use router.push({ name: &#8220;yourroutename&#8221;}) or just router.push(&#8220;yourroutename&#8221;) now to redirect.<\/p>\n\n\n\n<p><strong>42) What do you understand by slots in Vue.js?<\/strong><\/p>\n\n\n\n<p>In Vue.js, the &lt;slot&gt; element is used to serve as distribution outlets for content.<\/p>\n\n\n\n<p>Let&#8217;s take an example to create an alert component with slots for content insertion.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<p>In Vue.js, the &lt;slot&gt; element is used to serve as distribution outlets for content.<\/p>\n\n\n\n<p>Let&#8217;s take an example to create an alert component with slots for content insertion.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-21\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\">Vue.component('alert', {  \r\n  template: `  \r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"alert-box\"<\/span>&gt;<\/span>  \r\n      <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">strong<\/span>&gt;<\/span>Error!<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">strong<\/span>&gt;<\/span>  \r\n      <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">slot<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">slot<\/span>&gt;<\/span>  \r\n    <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>`  \r\n})  \r\nWe can insert dynamic content as follows:\r\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">alert<\/span>&gt;<\/span>  \r\n  There is an issue with in application.  \r\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">alert<\/span>&gt;<\/span>  \r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-21\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>43) What are the problems solved by Single File Components in Vue.js?<\/strong><\/p>\n\n\n\n<p>In Vue.js, the Single File Components are used to solve the common problems in a JavaScript-driven application with a .vue extension.<\/p>\n\n\n\n<p>Following is a list of issues solved by Single File Components in Vue.js:<\/p>\n\n\n\n<p>Global definitions specify unique names for every component.<\/p>\n\n\n\n<p>String templates lack syntax highlighting and require ugly slashes for multiline HTML.<\/p>\n\n\n\n<p>No CSS support. It means while HTML and JavaScript are modularized into components, CSS is conspicuously left out.<\/p>\n\n\n\n<p>No, build step restrictions to HTML and ES5 JavaScript, rather than preprocessors like Pug and Babel.<\/p>\n\n\n\n<p><strong>44) What are the different ways to create filters?<\/strong><\/p>\n\n\n\n<p><strong>&lt;&nbsp;<\/strong><\/p>\n\n\n\n<p>There are two ways to define filters:<\/p>\n\n\n\n<p>Local filters: You can define local filters in a component&#8217;s options. In this case, filter is applicable to that specific component.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-22\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">filters: {  \r\n  <span class=\"hljs-attr\">capitalize<\/span>: <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> (<span class=\"hljs-params\">value<\/span>) <\/span>{  \r\n    <span class=\"hljs-keyword\">if<\/span> (!value) <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-string\">''<\/span>  \r\n    valuevalue = value.toString()  \r\n    <span class=\"hljs-keyword\">return<\/span> value.charAt(<span class=\"hljs-number\">0<\/span>).toUpperCase() + value.slice(<span class=\"hljs-number\">1<\/span>)  \r\n  }  \r\n}  \r\nGlobal filters: You can also define a filter globally before creating the Vue instance. In <span class=\"hljs-keyword\">this<\/span> <span class=\"hljs-keyword\">case<\/span>, filter is applicable to all the components within the vue instance,\r\n\r\nVue.filter(<span class=\"hljs-string\">'capitalize'<\/span>, <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> (<span class=\"hljs-params\">value<\/span>) <\/span>{  \r\n  <span class=\"hljs-keyword\">if<\/span> (!value) <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-string\">''<\/span>  \r\n  valuevalue = value.toString()  \r\n  <span class=\"hljs-keyword\">return<\/span> value.charAt(<span class=\"hljs-number\">0<\/span>).toUpperCase() + value.slice(<span class=\"hljs-number\">1<\/span>)  \r\n})  \r\n<span class=\"hljs-keyword\">new<\/span> Vue({  \r\n  <span class=\"hljs-comment\">\/\/ ...  <\/span>\r\n})  \r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-22\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>45) What do you understand by mapState helper?<\/strong><\/p>\n\n\n\n<p>In the Vuex application, creating a computed property every time whenever we want to access the store&#8217;s state property or getter is going to be repetitive, difficult, and boring, especially if a component needs more than one state property. In this situation, we can use the mapState helper of vuex, which generates computed getter functions for us.<\/p>\n\n\n\n<p>In the following increment example, we have demonstrated the mapState helper:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-23\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">import<\/span> { mapState } <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">'vuex'<\/span>  \r\n<span class=\"hljs-keyword\">export<\/span> <span class=\"hljs-keyword\">default<\/span> {  \r\n  <span class=\"hljs-comment\">\/\/ ...  <\/span>\r\n  <span class=\"hljs-attr\">computed<\/span>: mapState({  \r\n    <span class=\"hljs-comment\">\/\/ arrow functions can make the code very succinct!  <\/span>\r\n    <span class=\"hljs-attr\">username<\/span>: <span class=\"hljs-function\"><span class=\"hljs-params\">state<\/span> =&gt;<\/span> state.username,  \r\n    <span class=\"hljs-comment\">\/\/ passing the string value 'username' is same as `state =&gt; state.username`  <\/span>\r\n    <span class=\"hljs-attr\">usernameAlias<\/span>: <span class=\"hljs-string\">'username'<\/span>,  \r\n    <span class=\"hljs-comment\">\/\/ to access local state with `this`, a normal function must be used  <\/span>\r\n     greeting (state) {  \r\n      <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-keyword\">this<\/span>.localTitle + state.username  \r\n    }  \r\n  })  \r\n}  \r\nYou can also pass a string array to mapState when the name <span class=\"hljs-keyword\">of<\/span> a mapped computed property is the same <span class=\"hljs-keyword\">as<\/span> a state sub-tree name\r\n\r\n<span class=\"hljs-attr\">computed<\/span>: mapState(&#91;  \r\n  <span class=\"hljs-comment\">\/\/ map this.username to store.state.username  <\/span>\r\n  <span class=\"hljs-string\">'username'<\/span>  \r\n])  \r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-23\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><strong>46) What are the most prominent features of stylelint?<\/strong><\/p>\n\n\n\n<p>Following is a list of the most prominent features of stylelint:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>The stylelint has more than 160 built-in rules to catch errors, apply limits and enforce stylistic conventions.<\/li><li>It understands the latest CSS syntax, including custom properties and level 4 selectors.<\/li><li>It extracts the embedded styles from HTML, markdown, and CSS-in-JS object &amp; template literals.<\/li><li>It is also used to parse CSS-like syntaxes like SCSS, Sass, Less, and SugarSS.<\/li><li>It supports for reusing community plugins and creating their plugins.<\/li><\/ul>\n\n\n\n<p><strong>47) What is a single-file component in Vue.js?<\/strong><\/p>\n\n\n\n<p>In Vue.js, a single-file component is a file with a .vue extension that contains a Vue component. The single-file component consists of the component&#8217;s template, logic, and styles, all bundled together in one file. It also contains one &lt;script&gt; block, optional &lt;template&gt; and &lt;style&gt; blocks, and possible additional custom blocks.<\/p>\n\n\n\n<p><strong>48) How to use a single-file component in Vue.js?<\/strong><\/p>\n\n\n\n<p>To use a single-file component in Vue.js, we have to set up Vue Loader for parsing the file (It is done automatically as a part of a webpack building pipeline). It also supports non-default languages such as Sass or HTML templating languages with pluggable pre-processors.<\/p>\n\n\n\n<p><strong>49) What is $parent property in Vue.js?<\/strong><\/p>\n\n\n\n<p>In Vue.js, the $parent property is used to access the parent instance from a child. It is similar to the $root property. The $parent property provides direct access, but it makes the application hard to test and debug. In this property, it is very difficult to find out where the mutation comes from.<\/p>\n\n\n\n<p><strong>50) What is $child property in Vue.js?<\/strong><\/p>\n\n\n\n<p>In Vue.js, the $child property is just like $parent property, but it is used to access the child instance.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Vue (pronounced \/vju\u02d0\/, like view) is a liberal framework for building user borders. Dissimilar other huge frameworks, Vue is designed from the ground up to be incrementally adoptable. The core library is absorbed on the view layer only, and is easy to pick up and mix with other libraries or existing projects. On the&#8230;<\/p>\n","protected":false},"author":1,"featured_media":26781,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[57],"tags":[5449,7283,7282,6592,6591,7284,7281,7280],"class_list":["post-26776","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-devopsschool","tag-js-interview-questions","tag-vue","tag-vue-template-compiler","tag-vue-js","tag-vue-js-interview-answers","tag-vue-js-training","tag-vue-js-tutorials"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/26776","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=26776"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/26776\/revisions"}],"predecessor-version":[{"id":26789,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/26776\/revisions\/26789"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/26781"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=26776"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=26776"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=26776"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}