Posts

Showing posts with the label vue js

Frequently asked: Vue.JS Interview Questions and Answers

Image
  Q1. What is Vue.js? What are the advantages of it? Vue is a progressive framework used to building user interfaces.The core library is focused on the view layer only, and is easy to pick up and integrate with other libraries or existing projects. Following are the advantages of using Vue.js. Small in size — The size of this framework is 18 to 21KB and it takes no time for the user to download and use it. Easy to Understand — One of the reasons for the popularity of this framework is that it is quite easy to understand. The user can easily add Vue.js to his web project because of its simple structure. Simple Integration — Vue.js can be integrated with the existing applications easily. Flexibility — This flexibility also makes it easy to understand for the developers of React.js, Angular.js, and any other new JavaScript framework. Virtual DOM — It uses virtual DOM similar to other existing frameworks such as ReactJS, Ember etc. Virtual DOM is a light-weight in-memory tre...

The difference between COMPUTED and METHODS in Vue.js

Image
  They are very similar and could be used to do same things many times but at the same time they are very different and need to be used in different ways. Methods They are static functions usually used to react to events which happen in the DOM and they accept arguments . They are incredibly useful for connecting functionality to events, or even just creating small parts of logic to be reused. You can call a method inside another method, they are very versatile! They are often used to run a functionality from the DOM. i.e. You want to show an output when a user click a button. Computed properties They don’t accept arguments and they are very handy for composing new data from existing sources, they get dynamic values based on other properties. They are often used to do calculation and at the end to return a value. i.e. You are rendering a list of items ordered by date. Here a simple example that makes the idea: var vm = new Vue({ el: '#vue-app', data: { firstname...

How to reverse string in vue js

Image
  HTML part : - < div id = "example" > < p > Original message: "{{ message }}" </ p > < p > Computed reversed message: "{{ reversedMessage }}" </ p > </ div >   JS Part : -   var vm = new Vue({ el : '#example' , data : { message : 'Hello' }, computed : { // a computed getter reversedMessage : function ( ) { // `this` points to the vm instance return this .message.split( '' ).reverse().join( '' ) } } })