<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. Linux Shell编程与编辑器使用详解

    <Linux Shell编程与编辑器使用详解> 基本信息 作者: 刘丽霞 杨宇 出版社:电子工业出版社 ISBN:9787121207174 上架时间:2013-7-22 出版日期:201 ...

  2. text-align 属性,输入框数字向右靠

    1.业务需求:金额输入框数字向右靠 2.HTML文件 <td id="otherPay_Td"> <input id="otherPay" t ...

  3. Spring Dataflow批处理框架在OCP上的部署

    详细参考 https://donovanmuller.blog/spring-cloud-dataflow-server-openshift/docs/1.2.1.RELEASE/reference/ ...

  4. Django出现的错误1.TypeError: view must be a callable or a list/tuple in the case of include().1.TypeError: view must be a callable or a list/tuple in the case of include().

    .TypeError: view must be a callable or a list/tuple in the case of include(). 原因: url(r"^upload ...

  5. es服务

    #!/bin/bash #chkconfig:2345 20 90 #description: elastic service #processname: elastic ROOT_PATH=/es5 ...

  6. 异常解决:util.NativeCodeLoader: Unable to load native-hadoop library for your platform

    内容源自:点此链接 刚装好hadoop的时候,每次输入命令运行都会出现: WARN util.NativeCodeLoader: Unable to load native-hadoop librar ...

  7. 在Linux命令行下查询当前所使用的shell版本与种类的方法

    原文: https://www.jb51.net/LINUXjishu/407463.html ---------------------------------------------------- ...

  8. linux mysql 更改MySQL数据库目录位置

    MySQL默认的数据文件存储目录为/var/lib/mysql.假如要把目录移到/home/data下需要进行下面几步: 1.home目录下建立data目录 cd /home mkdir data 2 ...

  9. Centos 7 搭建蓝鲸3.1.5社区版

    第一次搭建蓝鲸平台,参考了蓝鲸社区的官方搭建文档. 友情链接:蓝鲸智云社区版V3.1用户手册 搭建时遇到了不少的坑,这里做一个详细的安装梳理 主机硬件要求 官方的推荐如下: 我在公司测试环境搭建时机器 ...

  10. JMeter 四:建立高级web测试计划

    发送带有Header的请求 参考:http://jmeter.apache.org/usermanual/build-adv-web-test-plan.html#header_manager Jme ...