Skip to content

Tag: vuejs2

Vue2 modal in v-for list

I’m trying to implement a vue2 modal as described in the vue docs at https://v2.vuejs.org/v2/examples/modal.html. It looks something like this: While the button shows up and does pop up the modal, I get a warning that Property or method “item” is not defined on the instance but referenced du…

Vue js – Set alt image when image source not found

I am working on a site which has a list of products. Each product has a corresponding image. I am binding the image url to the source attribute like below. If the image is not found, I want to show a default image. I do as below in cshtml razor syntax (for reference only) How do I achieve the same

how to add or remove class in vuejs 2 based on id

I want to add or remove class to an element based on id using vuejs, but this code applies the behaviour to all elements. How can I add/remove a class to the element by id? Thanks all in advance. Answer Here is an example of using components to achieve the behavior you are looking for:

How to run method when a div re-init – Vuejs

I try and isRun variable’s change dynamic (switch by user) and i want myMethod and myMethod2 re-run when div re-init. But I try with v-html it only run first time. How to do that. thank. Answer So if you are strictly want to use this methods, computed properties watch their dependencies for changes befo…