Answers for "modal in vue js"

1

boostrap vue open modal in child component

Parent.vue 
<template>
	<button @click="openModal()">Open Child Component</button>
    <child-component-with-modal ref="childComponent">
    </child-component-with-modal>
</template>
<script>

export default {
	data() {..}
    methods: {
    	openModal(){
        	//access the childComponent via ref
            //access its children and use the correct index for
            //your targeted boostrap vue modal
            //use the show property which is the boostrap show method
        	
            this.$refs.childComponent.$children[0].show();
            
            //sometimes it helps to console log the ref to see all
            //available properties of ref element and its children
            
            console.log(this.$refs.childComponent);
        }
    }
}
</script>

Single File Component Child.vue
<template>
	<div>
    	...
    </div>	
	<b-modal @ok="confirmed()" @cancel="canceled()" @close="canceled()">
	</b-modal>
</template>
<script>

export default {
	data() {..}
    methods: {...}
}
</script>
Posted by: Guest on August-26-2020
1

how use moduls in vue

const moduleA = {
  state: () => ({ ... }),
  mutations: { ... },
  actions: { ... },
  getters: { ... }
}

const moduleB = {
  state: () => ({ ... }),
  mutations: { ... },
  actions: { ... }
}

const store = new Vuex.Store({
  modules: {
    a: moduleA,
    b: moduleB
  }
})

store.state.a // -> `moduleA`'s state
store.state.b // -> `moduleB`'s state
Posted by: Guest on June-18-2021
0

vue modal custom component

<vue-modaltor
    :visible="open"
    @hide="open = false">
        <p>
        Lorem ipsum dolor sit amet
        ....
  </vue-modaltor>
Posted by: Guest on May-28-2021

Browse Popular Code Answers by Language