: Unknown custom element: <cc-text-area> - Did you register the component correctly?
P粉717595985
2023-08-30 23:38:03
<p>I am making a component InputText.vue as shown below: </p>
<pre class="brush:php;toolbar:false;"><template>
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<h4>Edit Text:</h4>
<textarea class="form-control" cols="50" rows="4" placeholder="Enter text here..." v-model="textBoxInput" @keyup="textChanged" ></textarea>
</div>
</div>
</div>
</template>
<script>
export default{
data: function(){
return {
textBoxInput: ""
}
},
methods: {
textChanged: function(){
this.$emit('displayTextChanged', this.textBoxInput);
}
}
}
</script></pre>
<p>Then I register and use it in the CardFront.vue component like this: </p>
<pre class="brush:php;toolbar:false;"><style>
.edit-area {
padding: 20px;
height: 800px;
background-color: #d2f9f9;
}
.card-display {
padding: 20px;
height: 800px;
}
</style>
<template>
<div class="row">
<div class="card col-sm-6 edit-area">
<cc-text-area></cc-text-area>
</div>
<div class="card col-sm-6 card-display">
</div>
</div>
</template>
<script>
import TextInput from './TextInput.vue'
export default{
components: {
ccTextArea: TextInput
}
}
<script></pre>
<p>It gives this error:
Error</p>
<p>Please help me. I'm using Vue version 2. Whenever I try to refresh the page, it gives an error like this: [Vue warn]: Unknown custom element: - Did you register the component correctly? For recursive components, make sure to provide the "name" option. </p>
Check whether the file name and component name match.
If you are using a component
importing TextInput
from "./TextInput.vue" then also make sure to name your component and optionally add thename
attribute as per the comments suggestions in.I solved this problem. Thank you all very much for your help. The problem is with the closing script tag in the CardFront.vue component.