Code Monkey home page Code Monkey logo

vuelearn's Introduction

介绍

声明式渲染

<div id="app" v-bind:title="title">
  {{ message }}
</div>
const app = new Vue({
  el: '#app',
  data: {
    title: `页面加载于 ${new Date().toLocaleString()}`,
    message: 'Hello Vue!',
  },
});

app.message = 'Hello World!';

条件与循环

<div id="app">
  <ol v-if="todos.lenght > 0">
    <li v-for="todo in todos">
      {{ todo.text }}
    </li>
  </ol>
</div>
const app = new Vue({
  el: '#app',
  data: {
    todos: [
      { text: '学习 JavaScript' },
      { text: '学习 Vue' },
      { text: '整个牛项目' },
    ],
  },
});

处理用户输入

<div id="app">
  <p>{{ message }}</p>
  <input v-model="message" />
  <button v-on:click="count++;">点击 {{ count }} 次</button>
</div>
const app = new Vue({
  el: '#app',
  data: {
    message: 'Hello Vue!',
    count: 0,
  },
});

组件化应用构建

<div id="app">
  <ol>
    <!-- <li is="todo-item"/> -->
    <todo-item
      v-for="item in groceryList"
      v-bind:todo="item"
      v-bind:key="item.id"
    ></todo-item>
  </ol>
</div>
Vue.component('todo-item', {
  props: ['todo'],
  template: '<li>{{ todo.text }}</li>',
});

const app = new Vue({
  el: '#app',
  data: {
    groceryList: [
      { id: 0, text: '蔬菜' },
      { id: 1, text: '奶酪' },
      { id: 2, text: '随便其它什么人吃的东西' },
    ],
  },
});

vuelearn's People

Watchers

James Cloos avatar 李鸿章 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.