<div id="todo-list-example">
<input
v-model="newTodoText"
v-on:keyup.enter="addNewTodo"
placeholder="Add a todo"
>
<ul>
<li
is="todo-item"
v-for="(todo, index) in todos"
v-bind:key="todo.id"
v-bind:title="todo.title"
v-on:remove="todos.splice(index, 1)"
></li>
</ul>
</div> Vue.component('todo-item', {
template: '\
<li>\
{{ title }}\
<button v-on:click="$emit(\'remove\')">X</button>\
</li>\
',
props: ['title']
}) new Vue({
el: '#todo-list-example',
data: {
newTodoText: '',
todos: [
{
id: 1,
title: 'Do the dishes',
},
{
id: 2,
title: 'Take out the trash',
},
{
id: 3,
title: 'Mow the lawn'
}
],
nextTodoId: 4
},
methods: {
addNewTodo: function () {
this.todos.push({
id: this.nextTodoId++,
title: this.newTodoText
})
this.newTodoText = ''
}
}
})

todos Vue的更多相关文章

  1. vue父子通信

    首先在组件创建中创建子组件Todos.vue <template> <div class="hello"> <h1>todos show< ...

  2. Vue作用域插槽:用作循环结构的模版

    一 项目结构 二 App组件 <template> <div id="app"> <!-- 子组件 --> <todos :list=&q ...

  3. vue 【 子子组件 => 子组件 => 父组件 】 的事件和参数的传递

    1,子子组件  TodoItem.vue     <template>   <div class="todo-item" :class="{'is-co ...

  4. vue - 子组件向父组件 传递方法和参数

    1,子组件 TodoItem.vue  : <template>   <div class="todo-item" :class="{'is-compl ...

  5. [Vuex] Split Vuex Store into Modules using TypeScript

    When the Vuex store grows, it can have many mutations, actions and getters, belonging to different c ...

  6. [Vuex] Perform Async Updates using Vuex Actions with TypeScript

    Mutations perform synchronous modifications to the state, but when it comes to make an asynchronous ...

  7. [Vuex] Create a Vuex Store using TypeScript

    A Vuex store centralizes the state of your app, making it easy to reason about your state flow. In t ...

  8. Nuxt使用Vuex

    Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式.它采用集中式存储管理应用的所有组件的状态,并以相应的规则保证状态以一种可预测的方式发生变化. 基础知识这里不再重述,学习的话请自行到官网 ...

  9. 框架入门经典项目TodoMVC

    一.项目介绍 ①地址:http://todomvc.com/ ②GitHub下载模板 ③通过npm下载模板的样式 ④通过npm下载Vuejs ⑤项目文件,主要修改app.js和index.html两个 ...

随机推荐

  1. mongo 实时同步工具 mongosync

    文档地址:https://github.com/Qihoo360/mongosync/wiki/%E4%BD%BF%E7%94%A8%E6%A0%B7%E4%BE%8B #数据全量备份mongodum ...

  2. iOS:CALayer核心动画层

    CALayer:核心动画层 简介: Core Animation 是跨平台的,支持iOS环境和Mac OS X环境 学习核心动画之前,需要先理解CALayer,因为核心动画操作的对象不是UIView, ...

  3. 转:ios review推送与执行

    http://mp.weixin.qq.com/s?__biz=MzA4ODk0NjY4NA==&mid=409082578&idx=1&sn=2ca1e453d3c21caa ...

  4. SQL多表连接查询(具体实例)

    本文主要列举两张和三张表来讲述多表连接查询. 新建两张表: 表1:student  截图例如以下: 表2:course  截图例如以下: (此时这样建表仅仅是为了演示连接SQL语句.当然实际开发中我们 ...

  5. java线程总结(3/5)

    一.线程同步和死锁问题 异步问题: package com.horizon.action; /** * 测试同步问题 * */ public class TestSync { public stati ...

  6. Android编程心得-使用ActionBar+Fragment+ViewPager实现动态切换Menu效果

    1.首先上效果图 2.本例实现的效果主要适用于当前页面有多个页签时.进行Fragment切换时,能够利用不同的Menu样式与当前Fragment中的内容进行配合,能够大大添加复用性,看到效果图后,以下 ...

  7. App服务端架构变迁

    随着移动互联网时代的到来,移动技术也随之飞速发展.如今,App已然成为绝大多数互联网企业用来获取用户的核心渠道.以往以PC为主要承载平台的各业务线,源源不断集成加入到移动项目中来,原本以产品为中心快速 ...

  8. Browsers 之 弹出窗口阻止问题

    主要关注两个地方: 1.Microsoft Edge 浏览器: 浏览器 “ 设置 → 查看高级设置 ”,找到 “ 阻止弹出窗口 ”,关闭. 2.IE浏览器 [1] “ 工具 → 弹出窗口阻止程序 ”, ...

  9. HTML5 移动端如何使用css让百分比布局的弹窗水平和垂直方向上居中

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. Docker学习笔记之一,搭建一个JAVA Tomcat运行环境(转)

    前言 Docker旨在提供一种应用程序的自动化部署解决方案,在 Linux 系统上迅速创建一个容器(轻量级虚拟机)并部署和运行应用程序,并通过配置文件可以轻松实现应用程序的自动化安装.部署和升级,非常 ...