【发布时间】:2018-06-10 15:28:09
【问题描述】:
我正在使用 VueJS Vuetify framework,我需要从另一个模板打开一个对话框 - 作为组件模板导入。单击 App.vue 中的 Menu 按钮 后,Modal 应该会打开。 这是我的设置:
- App.vue = 带有菜单按钮的导航模板
- Modal.vue = 模态模板,在 main.js 中作为全局导入
main.js
import Modal from './components/Modal.vue'
Vue.component('modal', Modal)
Modal.vue 模板:
<template>
<v-layout row justify-center>
<v-btn color="primary" dark @click.native.stop="dialog = true">Open Dialog</v-btn>
<v-dialog v-model="dialog" max-width="290">
<v-card>
<v-card-title class="headline">Use Google's location service?</v-card-title>
<v-card-text>Let Google help apps determine location. This means sending anonymous location data to Google, even when no apps are running.</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="green darken-1" flat="flat" @click.native="dialog = false">Disagree</v-btn>
<v-btn color="green darken-1" flat="flat" @click.native="dialog = false">Agree</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</v-layout>
</template>
<script>
export default {
data () {
return {
dialog: false
}
}
}
</script>
如何打开对话框?
【问题讨论】:
标签: javascript vuejs2 vue-component vuetify.js