zoukankan      html  css  js  c++  java
  • vue 组件 组件2

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Title of page</title>
    </head>
    <body>
    <div id="example">
    <my-component></my-component>
    </div>
    <div id="example-2">
    <simple-counter></simple-counter>
    <simple-counter></simple-counter>
    <simple-counter></simple-counter>
    </div>


    </body>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.5.13/dist/vue.js"></script>
    <script >
    var Child = {
    template: '<div>A custom component!</div>'
    }
    // 注册
    // Vue.component('my-component', {
    // template: Child
    // })

    // 创建根实例
    new Vue({
    el: '#example',
    components: {
    // <my-component> 将只在父组件模板中可用
    'my-component': Child
    }
    })
    var data = { counter: 0 }

    Vue.component('simple-counter', {
    template: '<button v-on:click="counter += 1">{{ counter }}</button>',
    // 技术上 data 的确是一个函数了,因此 Vue 不会警告,
    // 但是我们却给每个组件实例返回了同一个对象的引用
    data: function () {
    return {
    counter: 0
    }
    }
    })

    new Vue({
    el: '#example-2'
    })
    </script>
    </html>

  • 相关阅读:
    各种小知识
    基础技能
    st表
    有理数取余
    FFT加速高精度乘法
    unique
    离散化
    线段树复杂度分析
    楼房重建
    电脑装系统常用方法
  • 原文地址:https://www.cnblogs.com/dianzan/p/8504047.html
Copyright © 2011-2022 走看看