javascript - 如何在 vuetify vue.js 应用程序中分离 <v-navigation-drawer> ?

标签 javascript vue.js vuejs2 vuetify.js

我正在尝试从我的应用程序的 <v-navigation-drawer> 创建一个组件,我看到一个错误:

Unknown custom element: <app-navigation-drawer> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

作为 vue.js 的新手,我已经弄清楚了要在特定 route 中使用的组件,但无法弄清楚在主App.vue中使用自定义组件文件。

我已经尝试过importing并将其添加为 component在Vue实例中,我也尝试过 importing它在App.vue内并将其作为组件导出默认组件。

:有人可以帮助我了解我需要在哪里注册此组件,或者我做错了什么吗?

App.vue

<template>
  <div id="app">
    <v-app>
      <app-navigation-drawer/>

      </v-toolbar>
      <v-content>
        <v-container class="grey lighten-5" fluid="fluid" fill-height="fill-height">
          <router-view></router-view>
        </v-container>
      </v-content>
    </v-app>
  </div>
</template>

ma​​in.js

import Vue from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
import Vuetify from 'vuetify';

import NavigationDrawer from './views/NavigationDrawer.vue';
Vue.use(Vuetify);
new Vue({
  router,
  store,
  components: { NavigationDrawer },
  render: h => h(App)
}).$mount('#app');

NavigationDrawer.vue

<template>
    <v-navigation-drawer app stateless value="true">Drawer</v-navigation-drawer>
</template>
<script>
export default {
    name: 'app-navigation-drawer'
}
</script>

最佳答案

建议您像这样声明您的组件:

components: { 'app-navigation-drawer': NavigationDrawer }

这应该有效。

如果您想直接执行此操作,请使用声明的名称:

<NavigationDrawer></NavigationDrawer>

引用:https://v2.vuejs.org/v2/guide/components-registration.html

关于javascript - 如何在 vuetify vue.js 应用程序中分离 <v-navigation-drawer> ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52451325/

相关文章:

javascript - 用animate()替换fadeIn/fadeOut即可平滑向左滑动

javascript - 当内容明显正确时,如何修复 XMLHttpRequest.open() 返回代码 0?

javascript - textarea 是最适合显示/隐藏链接文本的 UI 元素,就像在 Google map 中一样吗?

python - 通过 axios 将数据发送到 django rest 框架时获取错误请求 400

javascript - Vue js在不同文件中分离路由

javascript - 如何在 nuxt.js 中安装 Vue 包

javascript - Vuejs + Vuetifyjs + v-text-field 文本转换大写

JavaScript - `document.head.appendChild` src 和 href 中缺少请求 cookie

javascript - PlayStation 4 互联网浏览器上的 Vuejs 和 Bootstrap 4

vue.js - 绑定(bind)到 vue.js 中的数组字段