vue-material: 未知自定义组件 md-drawer & md-content

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

正在尝试渲染 md-drawer 组件和 md-content 组件。但是我无法克服这个错误。

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

<md-content> 组件有相同的错误消息。

这是代码。

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)
})

您大概可以看出这段代码几乎是直接从 the vue-material docs 复制和粘贴的。因此,我几乎可以肯定问题必须来自 main.js,但我看不到,也许其他人可以。

此外,欢迎任何关于我可能做错的任何事情的额外指示,或者任何关于 Vue 的一般信息!

https://vuematerial.io 的信息与 github 不同步。

1) 检查您的 node_modules/vue-material/components/ 查看您是否有文件夹 MdDrawer

2) 可以看到文件存在于github https://github.com/vuematerial/vue-material

3) 您可能需要按照 github 中所述进行安装 npm install vue-material@beta --save

在 运行 之前,确保执行 npm uninstall vue-material 以删除前一个。