A custom directive similar to v-if in vuejs

Try to use this hack: Vue.directive(‘permission’, (el, binding, vnode) => { if (!isUserGranted(binding.value)) { // replace HTMLElement with comment node const comment = document.createComment(‘ ‘); Object.defineProperty(comment, ‘setAttribute’, { value: () => undefined, }); vnode.elm = comment; vnode.text=” “; vnode.isComment = true; vnode.context = undefined; vnode.tag = undefined; vnode.data.directives = undefined; if (vnode.componentInstance) { vnode.componentInstance.$el = … Read more

Is it possible to change props value from method in Vue component?

What you are doing will throw a warning in Vue (in the console). [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop’s value. Prop being mutated: “propRoomSelected” The value will actually change inside the component, … Read more

Parsing error: No Babel config file detected

I had the same issue and this change fixed the issue. In your .eslintrc.js file, add requireConfigFile: false parserOptions: { parser: ‘@babel/eslint-parser’, requireConfigFile: false, // <== ADD THIS ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features sourceType: ‘module’ // Allows for the use of imports }

What is better in Vue, v-if or v-show?

tl;dr Assuming the question is strictly about performance: v-show: expensive initial load, cheap toggling, v-if: cheap initial load, expensive toggling. Evan You provided a more in depth answer at VueJS Forum v-show always compiles and renders everything – it simply adds the “display: none” style to the element. It has a higher initial load cost, … Read more