0

i'am trying to attach a vue component with a tag

MyComponent.vue

<template>
    <div>
        <h1>Hi</h1>
    </div>
</template>

<script>
export default {

}
</script>

this is app.js

require('./bootstrap');

window.Vue = require('vue');

import MyComponent from './components/MyComponent.vue';

Vue.component('myComponent', MyComponent);


const app = new Vue({
    el: '#app'
})

And this is the body of my welcome.blade

<body>
    <div id="app">
        <myComponent></myComponent>
    </div>

    <script src="{{ mix('js/app.js') }}"></script>
</body>

and i get this error

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

1
  • 1
    check public/js/app.js file is there if not then run npm run watch comand Commented Nov 16, 2020 at 12:45

2 Answers 2

0

In general, before the ending </body> tag. Check this link for referance

<body>
  <div id="app">
    <my-component></my-component>
  </div>

   <script src="{{ asset('js/app.js') }}"></script>
</body>
Sign up to request clarification or add additional context in comments.

Comments

0

try this as vuejs use case sensitive

Vue.component('my-component', require('./components/MyComponent.vue').default);

and html

<body>
    <div id="app">
        <my-component></my-component>
    </div>

    <script src="{{ mix('js/app.js') }}"></script>
</body>

ref link https://v2.vuejs.org/v2/style-guide/

1 Comment

@user7385152 import same as i m doing and compile your js

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.