Estoy tratando de que se reconozca este componente de encabezado y simplemente no lo es. Intenté modificar la configuración de eslint en estricto y modificar mi sintaxis sin éxito. No lo entiendo, esto debería ser tan simple. Cualquier ayuda sería apreciada.
aplicación.vue
<template> <div class="container"> <header /> </div> </template> <script> import header from './components/header' export default { name: 'App', components: { header, } } </script> <style> </style>principal.js
import { createApp } from 'vue' import App from './App.vue' createApp(App).mount('#app')índice.html
<!DOCTYPE html> <html lang=""> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <link rel="icon" href="<%= BASE_URL %>favicon.ico"> <title><%= htmlWebpackPlugin.options.title %></title> </head> <body> <noscript> <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong> </noscript> <div id="app"> </div> <!-- built files will be auto injected --> </body> </html>encabezado.vue
<template> <header> <h1>Component header</h1> </header> </template> <script> export default { name: 'header', }; </script> <style> header { display: flex; } </style>Cualquier ayuda sería increíble. Gracias.
El main.js debe importarse en index.html :
<body> <div id="app"></div> <script type="module" src="/src/js/main.js"></script> </body>(usando la ruta correcta)
Es mejor cambiar el nombre de su componente de encabezado a otra palabra, porque <header> se usa como un nombre de etiqueta estándar en html