vuematerial / vue-material

Vue.js Framework - ready-to-use Vue components with Material Design, free forever.
https://www.creative-tim.com/vuematerial
MIT License
9.88k stars 1.16k forks source link

Error when using MdDialogAlert as Individual component #2332

Closed givehug closed 1 year ago

givehug commented 3 years ago

Steps to reproduce

<template>
  <div>
    <MdDialogAlert
      :md-active.sync="first"
      md-content="Your post has been deleted!"
      md-confirm-text="Cool!"
    />
    <MdButton class="md-accent md-raised" @click="first = true">Alert</MdButton>
  </div>
</template>

<script>
import Vue from 'vue';

import { MdButton, MdDialogAlert } from 'vue-material/dist/components';

Vue.use(MdButton);
Vue.use(MdDialogAlert);

export default {
  data: () => ({
    first: false,
    second: false
  })
};
</script>

render and click on the button

Which browser?

all

What is expected?

no error

What is actually happening?

Unknown custom element: <md-dialog-content> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
Unknown custom element: <md-dialog-actions> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

Thoughts

I guess I have import and register md-dialog-content and md-dialog-actions myself, but

huffypiet commented 1 year ago

Have you considered where you placed the Vue.use()

huffypiet commented 1 year ago
<template>
  <div>
    <MdDialogAlert
      :md-active.sync="first"
      md-content="Your post has been deleted!"
      md-confirm-text="Cool!"
    />
    <MdButton class="md-accent md-raised" @click="first = true">Alert</MdButton>
  </div>
</template>

<script>
export default {
  name: "App",
  data: () => ({
    first: false,
    second: false
  })
};
</script>

Omitting imports and rather only including Vue.use(VueMaterial) in the entry point, index.js or main.js should cater for all individual use cases without you having to individually import components you wish to use.