现在位置: 首页  >  编程技术  >  前端  >  html直接引用vue3的 demo
html直接引用vue3的 demo
0 4546 转自:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<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>


 评论
 站内搜索