\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\nVue.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!
Every Vue application starts by creating a new Vue instance with the Vue function:
var vm = new Vue({
// options
})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.
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
└─ TodoListStatisticsAll Vue components are also Vue instances.
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.
You have access to a $route object from your components, that expose what we need.
//from your component
console.log(this.$route.query.test)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.
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>If you've created your project like this:
vue init webpack myprojectNow you can run
npm run buildThen copy index.html and /dist/ folder into your website root directory. Done.
Vue js comes with following features
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'
}
}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>'
})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>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>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).
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...