在html5页面中如何使用vue3_html页面引入vue组件
今天是2021.7.14,是个好日子.好久没发布文章了.今天发布下如何在在html页面中使用vue3.义县游学电子科技一直以技术文章为主.以下是h5的页面源码:
<html>
<script src="https://unpkg.com/vue@next"></script>
<body>
<div id="vue">
<div v-html="rhtml"></div>
<props-demo-simple></props-demo-simple>
</div>
</body>
<script>
const htmls={
data(){
return{
rhtml:"<h1>html页面中引用VUE3的演示页面</h1>",
}
}
}
const app=Vue.createApp(htmls)
// 简单语法注册或获取全局组件.注册还会自动使用给定的 id 设置组件的名称
app.component('props-demo-simple', { data() {
return {
count: 0
}
},
props: ['size', 'myMessage'],template: `
<button v-on:click="count++">
You clicked me {{ count }} times.
</button>`
}
)
app.mount("#vue")
</script>
</html>
分析下:首先<script src="https://unpkg.com/vue@next"></script>,引入vue3的脚本地址. 然后在body下的<script>中书写vue3的代码即可. 下图是运行的结果效果
相关文章
- Spring Boot中对接Twilio以实现发送验证码和验证短信码
- Spring Boot 3.5:这次更新让你连配置都不用写了,惊不惊喜?
- Spring Boot+Pinot实战:毫秒级实时竞价系统构建
- SpringBoot敏感配置项加密与解密实战
- SpringBoot 注解最全详解,建议收藏!
- Spring Boot 常用注解大全:从入门到进阶
- SpringBoot启动之谜:@SpringBootApplication如何让配置化繁为简
- Springboot集成Kafka原理_spring集成kafka的原理
- Spring Boot中@Data注解的深度解析与实战应用
- 大佬用1000字就把SpringBoot的配置文件讲的明明白白!
