\n```"}},{"@type":"Question","name":"What are Components in Vue.js?","acceptedAnswer":{"@type":"Answer","text":"*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.\n\nFollowing is the way to register a Vue component inside another component:\n```js\nexport default {\n el: '#your-element'\n components: {\n 'your-component'\n }\n}\n```"}},{"@type":"Question","name":"How can you redirect to another page in Vue.js?","acceptedAnswer":{"@type":"Answer","text":"If you are using `vue-router`, you should use `router.go(path)` to navigate to any particular route. The router can be accessed from within a component using `this.$router`. `router.go()` changed in VueJS 2.0. You can use `router.push({ name: \"yourroutename\"})`or just `router.push(\"yourroutename\")` now to redirect. \n"}},{"@type":"Question","name":"How to use Gulp with Vue.js?","acceptedAnswer":{"@type":"Answer","text":"You can use `Vueify`. it's a `browserify` transform.\n\n```js\ngulp.task('browserify', function() {\n return gulp.src('src/js/main.js')\n .pipe(plumber())\n .pipe(browserify({\n debug: !env.p,\n transform: ['vueify']\n }))\n .pipe(gulpif(env.p, uglify()))\n .pipe(gulp.dest('build/js'));\n});\n```"}},{"@type":"Question","name":"What is the difference v-bind and v-model? Provide some code example.","acceptedAnswer":{"@type":"Answer","text":"`v-model` is a **two-way binding for form inputs**. It combines `v-bind`, which **_brings a js value_ **into the markup, and `v-on:input` to **_update the js value_**.\n\nConsider:\n```html\n\n```\nand it's just syntactic sugar for:\n```html\n\n```\n\n`v-model` works with all the basic HTML input types (text, textarea, number, radio, checkbox, select). You can use `v-model` with `input type=date` if your model stores dates as ISO strings (`yyyy-mm-dd`)."}},{"@type":"Question","name":"How can I fetch query parameters in Vue.js?","acceptedAnswer":{"@type":"Answer","text":"You have access to a `$route` object from your components, that expose what we need.\n\n```js \n//from your component\nconsole.log(this.$route.query.test)\n```"}},{"@type":"Question","name":"Explain the basic logical Vue.js app organisation","acceptedAnswer":{"@type":"Answer","text":"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’s component tree might look like this:\n\n```sh\nRoot Instance\n└─ TodoList\n ├─ TodoItem\n │ ├─ DeleteTodoButton\n │ └─ EditTodoButton\n └─ TodoListFooter\n ├─ ClearTodosButton\n └─ TodoListStatistics\n```\nAll Vue components are also Vue instances."}},{"@type":"Question","name":"What is the best way to create a constant, that can be accessible from entire application in VueJs ?","acceptedAnswer":{"@type":"Answer","text":"You can always define a variable outside of the Vue app scope and use it throughout the application.\n\n```js\n//const.js\nexport default {\n c1: 'Constant 1',\n c2: 'Constant 2'\n}\n```\nAnd:\n```js\n// component.vue\nimport const from './const';\n\nexport default {\n methods: {\n method() {\n return const.c1;\n }\n }\n}\n```"}},{"@type":"Question","name":"What is filters in Vue.js?","acceptedAnswer":{"@type":"Answer","text":"Vue.js allows you to define **filters** that can be used to apply common text formatting. Filters are usable in two places: mustache interpolations and v-bind expressions (the latter supported in 2.1.0+). Filters should be appended to the end of the JavaScript expression, denoted by the “pipe” symbol:\n\n```html\n\n{{ message | capitalize }}\n\n\n
\n```"}},{"@type":"Question","name":"How to pass an argument to Vue.js filters?","acceptedAnswer":{"@type":"Answer","text":"Consider:\n```js\nfilters:{\n currency: function(value, arg1){\n return arg1+value;\n}\n```\nAnd usage:\n```html\n\n
\n {{123 | currency('$') }}\n
\n```"}},{"@type":"Question","name":"How to deploy Vue.js app?","acceptedAnswer":{"@type":"Answer","text":"If you've created your project like this:\n```sh\nvue init webpack myproject\n```\nNow you can run\n```sh\nnpm run build\n```\nThen copy index.html and /dist/ folder into your website root directory. Done."}},{"@type":"Question","name":"What are components props?","acceptedAnswer":{"@type":"Answer","text":"Every component instance has its own isolated scope. This means you cannot (and should not) directly reference parent data in a child component’s 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.\n\n```js\nVue.component('blog-post', {\n // camelCase in JavaScript\n props: ['postTitle'],\n template: '

{{ postTitle }}

'\n})\n```"}},{"@type":"Question","name":"What's the equivalent of Angular Service in Vue.js?","acceptedAnswer":{"@type":"Answer","text":"There are 4 ways:\n\n* Stateless service: then you should use mixins\n* Statefull service: use Vuex\n* Export service and import from a vue code\n* any javascript global object"}},{"@type":"Question","name":"Why we need Vue.js mixins?","acceptedAnswer":{"@type":"Answer","text":"Mixins are a flexible way to _distribute reusable functionalities_ for Vue components. A mixin object can contain any component options. When a component uses a mixin, all options in the mixin will be “mixed” into the component’s own options. \n\nConsider:\n```js\n// define a mixin object\nvar myMixin = {\n methods: {\n getProducts () {\n myApi.get('products?id=' + prodId).then(response => this.product = response.data)\n }\n }\n}\n\n// define a component that uses this mixin\nvar Component = Vue.extend({\n mixins: [myMixin]\n})\n\n// alternate way to have a mixin while initialising\nnew Vue({\n mixins: [myMixin],\n created: function () {\n console.log('other code')\n }\n})\n```"}},{"@type":"Question","name":"What is Vuex?","acceptedAnswer":{"@type":"Answer","text":"\nVuex is a **state management pattern + library** for Vue.js applications. It serves as a centralized store for all the components in an application, with rules ensuring that the state can only be mutated in a predictable fashion. The basic idea behind Vuex, inspired by Flux, Redux and The Elm Architecture.\n\nVuex resolves two problems:\n* Multiple views may depend on the same piece of state. Passing props can be tedious for deeply nested components, and simply doesn't work for sibling components. \n* Actions from different views may need to mutate the same piece of state. We often find ourselves resorting to solutions such as reaching for direct parent/child instance references or trying to mutate and synchronize multiple copies of the state via events. Both of these patterns are brittle and quickly lead to unmaintainable code."}},{"@type":"Question","name":"What is a proper way to communicate between sibling components in vuejs 2.0?","acceptedAnswer":{"@type":"Answer","text":"With Vue 2.0, we using the eventHub mechanism.\n\nConsider:\n```js\nconst eventHub = new Vue() // Single event hub\n\n// Distribute to components using global mixin\nVue.mixin({\n data: function () {\n return {\n eventHub: eventHub\n }\n }\n})\n// your component you can emit events with\nthis.eventHub.$emit('update', data)\n// And to listen you do\nthis.eventHub.$on('update', data => {\n// do your thing\n})\n```\nYou can even make it shorter and use root Vue instance as `global` Event Hub:\n```js\n// Component 1\nthis.$root.$emit('eventing', data);\n// Component 2\nmounted() {\n this.$root.$on('eventing', data => {\n console.log(data);\n });\n}\n```"}}]}
FullStackFSCCafé
 
 
Sign in with GoogleSign in with Google. Opens in new tab
Kill Your Tech Interview
3877 Full-Stack, Algorithms & System Design Interview Questions
Answered To Get Your Next Six-Figure Job Offer
      
🤖 Having Machine Learning & DS Interview? Check  MLStack.Cafe - 1704 Data Science & ML Interview Questions & Answers!Having ML & DS Interview? Check 🤖 MLStack.Cafe - 1704 ML & DS Interview Questions and Answers

20+ Vue.js Interview Questions (ANSWERED) Web Devs Should Know

Vue.js is already quite popular in 2019 and is growing very fast. According to IT Jobs Watch Vue.js developer earns - $54,297 USD. Follow along and explore 20+ essential Vue.js 2.0 interview questions and answers to land your perfect web developer job!

Q1: 
How to create an instance of Vue.js?

Answer

Every Vue application starts by creating a new Vue instance with the Vue function:

var vm = new Vue({
  // options
})

Having Tech or Coding Interview? Check 👉 41 Vue.js Interview Questions

Q2: 
What is Vue.js?

Answer

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’t need to install any thing to use Vue js just need add Vue js library in your project.


Having Tech or Coding Interview? Check 👉 41 Vue.js Interview Questions

Q3: 
Explain the basic logical Vue.js app organisation

Answer

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’s component tree might look like this:

Root Instance
└─ TodoList
   ├─ TodoItem
   │  ├─ DeleteTodoButton
   │  └─ EditTodoButton
   └─ TodoListFooter
      ├─ ClearTodosButton
      └─ TodoListStatistics

All Vue components are also Vue instances.


Having Tech or Coding Interview? Check 👉 41 Vue.js Interview Questions
Source: vuejs.org

Q4: 
Explain the differences between one-way data flow and two-way data binding?

Answer

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.

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.


Having Tech or Coding Interview? Check 👉 41 Vue.js Interview Questions

Q5: 
How can I fetch query parameters in Vue.js?

Answer

You have access to a $route object from your components, that expose what we need.

//from your component
console.log(this.$route.query.test)

Having Tech or Coding Interview? Check 👉 41 Vue.js Interview Questions

Q6: 
How can you redirect to another page in Vue.js?

Answer

If you are using vue-router, you should use router.go(path) to navigate to any particular route. The router can be accessed from within a component using this.$router. router.go() changed in VueJS 2.0. You can use router.push({ name: "yourroutename"})or just router.push("yourroutename") now to redirect.


Having Tech or Coding Interview? Check 👉 41 Vue.js Interview Questions

Q7: 
How to create Two-Way Bindings in Vue.js?

Answer

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.

In below example you can see how Two-Way Bindings is implemented.

<div id="app">
  {{message}}
  <input v-model="message">
</div>
<script type="text/javascript">
  var message = 'Vue.js is rad';
  new Vue({ el: '#app', data: { message } });
</script>

Having Tech or Coding Interview? Check 👉 41 Vue.js Interview Questions

Q8: 
How to deploy Vue.js app?

Answer

If you've created your project like this:

vue init webpack myproject

Now you can run

npm run build

Then copy index.html and /dist/ folder into your website root directory. Done.


Having Tech or Coding Interview? Check 👉 41 Vue.js Interview Questions
🤖 Having Machine Learning & DS Interview? Check  MLStack.Cafe - 1704 Data Science & ML Interview Questions & Answers!Having ML & DS Interview? Check 🤖 MLStack.Cafe - 1704 ML & DS Interview Questions and Answers

Q9: 
List some features of Vue.js

Answer

Vue js comes with following features

  • Templates
  • Reactivity
  • Components
  • Transitions
  • Routing

Having Tech or Coding Interview? Check 👉 41 Vue.js Interview Questions

Q10: 
What are Components in Vue.js?

Answer

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.

Following is the way to register a Vue component inside another component:

export default {
  el: '#your-element'
  components: {
      'your-component'
  }
}

Having Tech or Coding Interview? Check 👉 41 Vue.js Interview Questions

Q11: 
What are components props?

Answer

Every component instance has its own isolated scope. This means you cannot (and should not) directly reference parent data in a child component’s 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.

Vue.component('blog-post', {
  // camelCase in JavaScript
  props: ['postTitle'],
  template: '<h3>{{ postTitle }}</h3>'
})

Having Tech or Coding Interview? Check 👉 41 Vue.js Interview Questions

Q12: 
What is filters in Vue.js?

Answer

Vue.js allows you to define filters that can be used to apply common text formatting. Filters are usable in two places: mustache interpolations and v-bind expressions (the latter supported in 2.1.0+). Filters should be appended to the end of the JavaScript expression, denoted by the “pipe” symbol:

<!-- in mustaches -->
{{ message | capitalize }}

<!-- in v-bind -->
<div v-bind:id="rawId | formatId"></div>

Having Tech or Coding Interview? Check 👉 41 Vue.js Interview Questions

Q13: 
How to pass an argument to Vue.js filters?

Answer

Consider:

filters:{
   currency: function(value, arg1){
     return arg1+value;
}

And usage:

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.1/vue.js"></script>
<div id="vue-instance">
  {{123 | currency('$') }}
</div>

Having Tech or Coding Interview? Check 👉 41 Vue.js Interview Questions

Q14: 
What is the difference v-bind and v-model? Provide some code example.

Answer

v-model is a two-way binding for form inputs. It combines v-bind, which brings a js value into the markup, and v-on:input to update the js value.

Consider:

<input v-model="something">

and it's just syntactic sugar for:

<input
   v-bind:value="something"
   v-on:input="something = $event.target.value"
>

v-model works with all the basic HTML input types (text, textarea, number, radio, checkbox, select). You can use v-model with input type=date if your model stores dates as ISO strings (yyyy-mm-dd).


Having Tech or Coding Interview? Check 👉 41 Vue.js Interview Questions

Q15: 
How to use Gulp with Vue.js?

Answer
Join FullStack.Cafe to open this Answer. It's Free!
Sign in with GoogleSign in with Google. Opens in new tab
Join 120k+ Developer Who Trust FullStack.Cafe
🤖 Having Machine Learning & DS Interview? Check  MLStack.Cafe - 1704 Data Science & ML Interview Questions & Answers!Having ML & DS Interview? Check 🤖 MLStack.Cafe - 1704 ML & DS Interview Questions and Answers

Q16: 
What is Vuex?

Answer
Join FullStack.Cafe to open this Answer. It's Free!
Sign in with GoogleSign in with Google. Opens in new tab
Join 120k+ Developer Who Trust FullStack.Cafe

Q17: 
What's the equivalent of Angular Service in Vue.js?

Answer
Join FullStack.Cafe to open this Answer. It's Free!
Sign in with GoogleSign in with Google. Opens in new tab
Join 120k+ Developer Who Trust FullStack.Cafe

Q18: 
What is a proper way to communicate between sibling components in vuejs 2.0?

Answer
Unlock FullStack.Cafe to open all answers and get your next figure job offer!
Share this blog post to open Expert question!

Q19: 
What is the best way to create a constant, that can be accessible from entire application in VueJs ?

Answer
Unlock FullStack.Cafe to open all answers and get your next figure job offer!
Share this blog post to open Expert question!

Q20: 
Why we need Vue.js mixins?

Answer
Unlock FullStack.Cafe to open all answers and get your next figure job offer!
Share this blog post to open Expert question!
 

Rust has been Stack Overflow’s most loved language for four years in a row and emerged as a compelling language choice for both backend and system developers, offering a unique combination of memory safety, performance, concurrency without Data races...

Clean Architecture provides a clear and modular structure for building software systems, separating business rules from implementation details. It promotes maintainability by allowing for easier updates and changes to specific components without affe...

Azure Service Bus is a crucial component for Azure cloud developers as it provides reliable and scalable messaging capabilities. It enables decoupled communication between different components of a distributed system, promoting flexibility and resili...

Cosmos DB has gained popularity among developers and organizations across various industries, including finance, e-commerce, gaming, IoT, and more. Follow along and learn the 24 most common and advanced Azure Cosmos DB interview questions and answers...
More than any other NoSQL database, and dramatically more than any relational database, MongoDB's document-oriented data model makes it exceptionally easy to add or change fields, among other things. It unlocks Iteration on the project. Iteration f...
Unit Tests and Test Driven Development (TDD) help you really understand the design of the code you are working on. Instead of writing code to do something, you are starting by outlining all the conditions you are subjecting the code to and what outpu...
Domain-Driven Design is nothing magical but it is crucial to understand the importance of Ubiquitous Language, Domain Modeling, Context Mapping, extracting the Bounded Contexts correctly, designing efficient Aggregates and etc. before your next DDD p...
At its core, Microsoft Azure is a public cloud computing platform - with solutions including Infrastructure as a Service (IaaS), Platform as a Service (PaaS), and Software as a Service (SaaS) that can be used for services such as analytics, virtual c...
As an asynchronous event-driven JavaScript runtime, Node.js is designed to build scalable network applications. Follow along to refresh your knowledge and explore the 52 most frequently asked and advanced Node JS Interview Questions and Answers every...
Dependency Injection is most useful when you're aiming for code reuse, versatility and robustness to changes in your problem domain. DI is also useful for decoupling your system. DI also allows easier unit testing without having to hit a database and...