【发布时间】:2023-11-22 13:20:01
【问题描述】:
我正在尝试识别此标头组件,但它没有。我已经尝试将 eslint 设置为严格,并且弄乱我的语法无济于事。我不明白,这应该很简单。任何帮助将不胜感激。
App.vue
<template>
<div class="container">
<header />
</div>
</template>
<script>
import header from './components/header'
export default {
name: 'App',
components: {
header,
}
}
</script>
<style>
</style>
main.js
import { createApp } from 'vue'
import App from './App.vue'
createApp(App).mount('#app')
index.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>
header.vue
<template>
<header>
<h1>Component header</h1>
</header>
</template>
<script>
export default {
name: 'header',
};
</script>
<style>
header {
display: flex;
}
</style>
任何帮助都会很棒。谢谢。
【问题讨论】:
-
我认为
main.js没有导入到index.html中。 -
嘿,将其导入 head 标签有效!是否应该将其导入标题中?因为现在错误消失了,但是标题内容仍然没有显示,但是现在显示了标题样式(flex属性)。
-
见下面的答案...
标签: javascript vue.js vuejs3