zoukankan      html  css  js  c++  java
  • vue

    组件化应用构建

    <div id="components-app" class="demo">
      <ol>
        <!--
          Now we provide each todo-item with the todo object
          it's representing, so that its content can be dynamic.
          We also need to provide each component with a "key",
          which will be explained later.
        -->
        <todo-item
          v-for="item in groceryList"
          v-bind:todo="item"
          v-bind:key="item.id"
        ></todo-item>
      </ol>
    </div>
    .demo {
      font-family: sans-serif;
      border: 1px solid #eee;
      border-radius: 2px;
      padding: 20px 30px;
      margin-top: 1em;
      margin-bottom: 40px;
      user-select: none;
      overflow-x: auto;
    }
    const ComponentsApp = {
      data() {
        return {
          groceryList: [
            { id: 0, text: 'Vegetables' },
            { id: 1, text: 'Cheese' },
            { id: 2, text: 'Whatever else humans are supposed to eat' }
          ]
        }
      }
    }
    
    const app = Vue.createApp(ComponentsApp)
    
    app.component('todo-item', {
      props: ['todo'],
      template: `<li>{{ todo.text }}</li>`
    })
    
    app.mount('#components-app')

  • 相关阅读:
    vue系列——数据请求
    优化记录
    优化记录
    正则
    跨域问题
    原型链之prototype/__proto__/constructor
    vue系列——组件数据通讯(二)
    vue系列——组件数据通讯(一)
    ES6(一)
    ES5总结
  • 原文地址:https://www.cnblogs.com/yongyuandishen/p/14912527.html
Copyright © 2011-2022 走看看