Skip to content

Instantly share code, notes, and snippets.

@codebender828
Created July 3, 2019 07:10
Show Gist options
  • Save codebender828/3ad2a64a1f8c02db63bf425455a694e0 to your computer and use it in GitHub Desktop.
Save codebender828/3ad2a64a1f8c02db63bf425455a694e0 to your computer and use it in GitHub Desktop.
How to use modal component in parent component
<!-- Parent Component -->
<template>
<div>
<modal :show-modal="showModal">
<h1 slot="header">{{ title }}</h1>
<p slot="body">{{ body }}</p>
<div slot="footer">
<base-button
@click.native="hideModal"
>
{{ buttonMessage ? buttonMessage : 'Okay' }}
</base-button>
</div>
</modal>
</div>
</template>
<script>
import Modal from '@/components/modal/modal.vue'
import BaseButton from '@/components/buttons/button-base.vue'
export default {
name: 'InterpreterRoot',
components: {
Modal,
BaseButton
},
data() {
return {
// Passes this as prop to <modal /> component
showModal: false,
title: 'Modal title',
body: 'This is the modal text',
buttonMessage: 'Got it!'
};
},
methods: {
removeModal() {
this.showModal = false;
},
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment