试图渲染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>
。
这是此代码。
应用程序.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)
})
您可能会说这段代码几乎是从vue-material docs直接复制和粘贴的。因此,我几乎可以肯定问题必须来自main.js
,但我看不到它,也许其他人可以。
也欢迎任何关于我可能做的不正确的任何其他指示,或者任何关于 Vue 的一般情况!