vue局部组件

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
  </head>

  <body>
    <div id="app">
      <comp>
      </comp>
    </div>

    <script>
      // 创建的是 Vue 构造器
      const comp = Vue.extend({
        template: `
          <div id="">
            <p>Hello Vue.js!</p>
            <p>Hello furong!</p>
          </div>`
      })

      const app = new Vue({
        el: '#app',
        data: {
          message: 'Hello Vue.js!',
        },
        components: {
          comp: comp,
        }
      })
    </script>
  </body>
</html>

posted @ 2021-07-05 17:10  thomas_blog  阅读(46)  评论(0编辑  收藏  举报