Close dialog when ESC key is pressed

Add @keydown.esc=”dialog = false” to v-dialog component <v-dialog v-model=”dialog” @keydown.esc=”dialog = false”></v-dialog> data: () => ({ dialog: false }), Working example: https://codepen.io/anon/pen/BJOOOQ Additionally, if using dialog as custom component then possibly we need to emit input event: <template> <v-dialog :value=”value” @keydown.esc=”$emit(‘input’)”> …

Hiding vue.js template before it is rendered

Vue already has a v-cloak directive built in, you just need to add the relevant css class: [v-cloak] { display: none; } And then apply it to your element like so: <div v-cloak> {{message}} </div> Here’s the JSFiddle: https://jsfiddle.net/2jbe82hq/ If you remove v-cloak in that fiddle you will see the mustached {{message}} before the instance … Read more

Vue Trigger watch on mounted

As of Vue 2.0, there is now a way to do it in the watcher itself, using immediate: true. There’s a minor caveat for when in the lifecycle this runs the watcher, see edit. Before using this, ensure you really need a watcher rather than a computed property. There are many advantages to computed properties … Read more

use axios globally in all my components vue

In main.js you can just assign Axios to $http. main.js import Axios from ‘axios’ Vue.prototype.$http = Axios; By modifying the vue prototype, any vue instance will have the ability to call $http on this. (e.g. this.$http.get(‘https://httpbin.org/get’) Note: $http is the axios object now, so any method you can call on axios object, you can call … Read more

How to `emit` event out of `setup` method in vue3?

setup function takes two arguments, First one is props. And the second one is context which exposes three component properties, attrs, slots and emit. You can access emit from context like: export default { setup(props, context) { context.emit(‘event’); }, }; or export default { setup(props, { emit }) { emit(‘event’); }, }; Source

Vue-Cli: ‘title’ option for htmlWebpackPlugin does not work

Unfortunately the above answers didn’t help me. As stated in the offical documentation you only need to add the vue.config.js to your root folder and add the following: // vue.config.js module.exports = { chainWebpack: config => { config .plugin(‘html’) .tap(args => { args[0].title=”Your new title” return args }) } } Keep in mind that you … Read more

Component Inheritance with vue js

You should use Mixins to add common functionality to multiple (or all of your) components: https://v2.vuejs.org/v2/guide/mixins.html This will let you add the same functions to any or all of your components, so you can automatically add this.foobar() to your components. If you want to add functionality to all of your components without polluting your component … Read more