4
vue 请教为什么不能正常显示组件?
source link: https://www.v2ex.com/t/822767
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
用的 vite vue 初始化默认结构,在 main.ts 里定义且全局注册组件并默认 mount #app ,在 index.html 里引用组件,为什么不显示?
GhostBoy 16 分钟前
main.ts
```typescript
import { createApp } from 'vue'
import App from './App.vue'
createApp(App)
.component('blog-post', {
props: ['title'],
template: `<h4>{{ title }}</h4>`
})
.mount('#app'
```
```typescript
import { createApp } from 'vue'
import App from './App.vue'
createApp(App)
.component('blog-post', {
props: ['title'],
template: `<h4>{{ title }}</h4>`
})
.mount('#app'
```
GhostBoy 13 分钟前
index.html
<div id="app">
<blog-post title="My journey with Vue"></blog-post>
<blog-post title="Blogging with Vue"></blog-post>
<blog-post title="Why Vue is so fun"></blog-post>
</div>
<div id="app">
<blog-post title="My journey with Vue"></blog-post>
<blog-post title="Blogging with Vue"></blog-post>
<blog-post title="Why Vue is so fun"></blog-post>
</div>
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK