1

In Vue 3, when I register a component to use, I use the following in my .js file:

import blogpost from '../../../blogpost.vue'
app.use(blogpost);

I create a simple component, i.e. BlogPost.vue.

<!-- BlogPost.vue -->
<template>
    <h4>{{ title }}</h4>
</template>
<script>
    export default {
        name: 'BlogPost',
        props: ['title']
    }
</script>

In my html file, I call the following:

<div id="app">
    <blogpost title = 'test'/>
</div>

When I run the app, I get the following:

runtime-core.esm-bundler.js?fea0:38 [Vue warn]: Failed to resolve component: blogpost. If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.

It's like Vue can't render the component. I am using webpack to compile, so if I put the wrong location in, it errors out. So the location is right, I guess?

Is there something I am doing wrong?

1 Answer 1

2

I don't know whether you have solved this, anyway, here is the answer. Use app.component() to globally register a component (look here).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.