vuejs3.0 从入门到精通——DOM 中的根组件模板

DOM 中的根组件模板

https://cn.vuejs.org/guide/essentials/application.html#the-root-component

当在未采用构建流程的情况下使用 Vue 时,我们可以在挂载容器中直接书写根组件模板:

html:

1
2
3
<div id="app">
  <button @click="count++">{{ count }}</button>
</div>
js:
1
2
3
4
5
6
7
8
9
10
11
import { createApp } from 'vue'
 
const app = createApp({
  data() {
    return {
      count: 0
    }
  }
})
 
app.mount('#app')

当根组件没有设置template选项时,Vue 将自动使用容器的innerHTML作为模板。

posted @   左扬  阅读(217)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
levels of contents
点击右上角即可分享
微信分享提示