vue-material: unknown custom component md-drawer & md-content

4.5k Views Asked by At

Trying to render the md-drawer component and the md-content components. But I'm having trouble getting past this error.

[Vue warn]: Unknown custom element: <md-drawer> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

There is an identical error message for the <md-content> component.

Here's the code for this.

App.vue

<template>
  <div id="app" class="page-container md-layout-column">

      <div class="page-container md-layout-column">
        <md-toolbar class="md-primary">
          <md-button class="md-icon-button" @click="showNavigation = true">
            <md-icon>menu</md-icon>
          </md-button>
        </md-toolbar>

        <md-drawer :md-active.sync="showNavigation">
          <md-toolbar class="md-transparent" md-elevation="0">
            <span class="md-title">My App name</span>
          </md-toolbar>

          <md-list>
            <md-list-item>
              <md-icon>move_to_inbox</md-icon>
              <span class="md-list-item-text">Inbox</span>
            </md-list-item>

            <md-list-item>
              <md-icon>send</md-icon>
              <span class="md-list-item-text">Sent Mail</span>
            </md-list-item>

            <md-list-item>
              <md-icon>delete</md-icon>
              <span class="md-list-item-text">Trash</span>
            </md-list-item>

            <md-list-item>
              <md-icon>error</md-icon>
              <span class="md-list-item-text">Spam</span>
            </md-list-item>
          </md-list>
        </md-drawer>

        <md-content>
          <router-view></router-view>
        </md-content>
      </div>
  </div>
</template>

<script>
export default {
  name: "app",
  data: () => ({
    showNavigation: false,
    showSidepanel: false
  })
};
...
<style>...</style>

main.js

import Vue from 'vue'
import Vuex from 'vuex'
import VueRouter from 'vue-router'
import VueMaterial from 'vue-material'

import App from './App.vue'
import store from './store'
import routes from './router'

import 'vue-material/dist/vue-material.css'

const router = new VueRouter({
  routes
})

let colorPrimary = {
  color: 'green',
  hue: 700,
  hexa: '#42b883'
}

let colorAccent = {
  color: 'blue',
  hue: 600,
  hexa: '#35495e'
}

Vue.use(VueMaterial)

Vue.material.registerTheme('default', {
  primary: colorPrimary,
  accent: colorAccent,
  warn: colorPrimary,
  background: 'white'
})

Vue.material.setCurrentTheme('default')

Vue.use(Vuex)
Vue.use(VueRouter)

new Vue({
  el: '#app',
  store,
  router,
  render: h => h(App)
})

you can probably tell that this code is an almost direct copy and paste from the vue-material docs. Because of this I'm almost positive the issue has to be coming from main.js, but I can't see it, maybe someone else can.

Also any additional pointers about anything else I may be doing incorrectly, or anything about Vue in generald are welcome!

1

There are 1 best solutions below

1
On BEST ANSWER

The information of https://vuematerial.io is out of sync with github.

1) check in your node_modules/vue-material/components/ to see if you have the folder MdDrawer

2) you can see the file exists in github https://github.com/vuematerial/vue-material

3) you probably need to install this as stated in github npm install vue-material@beta --save

before running that, be sure you do an npm uninstall vue-material to remove the previous one.