第一种形式:

<body>
<div id="app">
    <aaa></aaa> <!--引用组件-->
</div>
<!--将模块独立出来-->
<template id="aaa">
    <h2>{{msg}}</h2>
</template>
</body>
<script src="./vue.js"></script>
<script>
    new Vue({
        el: '#app',
        data: function () {
            return {}
        },
        components: {
            /*局部组件*/
            'aaa': {
                data: function () {
                    return {
                        'msg': 'hello aaa'
                    }
                },
                template: "#aaa", /*此处挂载*/
                methods: {}
            },
            'bbb': {}
        }
    })
</script>

 

相关文章:

  • 2022-12-23
  • 2021-07-19
  • 2022-01-15
  • 2021-07-04
  • 2021-09-22
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
相关资源
相似解决方案