4

vue 请教为什么不能正常显示组件?

 2 years ago
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.
neoserver,ios ssh client

V2EX  ›  Vue.js

vue 请教为什么不能正常显示组件?

  GhostBoy · 16 分钟前 · 51 次点击

用的 vite vue 初始化默认结构,在 main.ts 里定义且全局注册组件并默认 mount #app ,在 index.html 里引用组件,为什么不显示?

GhostBoy

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'

```

GhostBoy

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>

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK