<template>
<div>
<ul>
<li v-for="(item,index) in cartoon" :key="index" :class="{'A':'red','B':'green','C':'yellow','D':'blue','E':'pink '}[item.score]">
{{item.name}},{{item.score}}
<button @click="deleteC(index)">删除</button>
</li>
</ul>
<input type="text" v-model="name" />
<input type="text" v-model="score" />
<button @click="addC">添加</button>

</div>
</template>

<script>
export default{
data(){

return{
name:'',
score:'',
cartoon:[
{id:'1',name:"加菲猫",score:"A"},
{id:'2',name:"哆啦A梦",score:"B"},
{id:'3',name:"葫芦娃",score:"C"},
{id:'4',name:"变形金刚",score:"D"},
{id:'5',name:"奥特曼",score:"E"}
]
}
},
methods:{
addC(){
this.cartoon.push({
name:this.name,
score:this.score
});
this.name='';
this.score='';
},
deleteC(index){
this.cartoon.splice(index);
}
}
}

</script>

<style>
.red{
background: red;
}
.green{
background: green;
}
.yellow{
background: yellow;
}
.blue{
background: blue;
}
.pink{
background: pink;
}
</style>

vue 样式渲染,添加删除元素的更多相关文章

  1. jQuery添加删除元素

    $(document).ready(function () { $('#radioExtranet').on('click', function () { showProjectInformation ...

  2. 分别使用原生js和jQuery添加/删除元素的class属性

    一.原生js添加/删除元素的class属性: <!-- span元素原有class = "test" --> <span class="test&quo ...

  3. Java ArrayList正确循环添加删除元素方法及分析

    在阿里巴巴Java开发手册中,有这样一条规定: 但是手册中并没有给出具体原因,本文就来深入分析一下该规定背后的思考. 一.foreach循环 foreach循环(Foreach loop)是计算机编程 ...

  4. 集合遍历过程iterator, 添加删除元素报异常

    list  set  遍历过程中添加或者删除元素,报异常. 使用iterator 也会报异常 ConcurrentModificationException remove只能用迭代器的remove,而 ...

  5. JS中的数组,添加删除元素,判断是否存在一个值的方法总结

    一.添加元素: 1:在最后添加,返回数组长度:arr.push(...); 2:在最前面添加,返回数组长度:arr.unshift(...); 3:在指定位置添加,没有返回值:arr[i] = xxx ...

  6. js添加删除元素内容

    <body> <div id="div" style="background: yellow;width:200px;height:200px;&quo ...

  7. JavaScript HTML DOM---遗漏知识再整理(向html添加/删除元素,改变内容和css)

    1.  HTML DOM 改变 HTML 内容:(HTML DOM 允许 JavaScript 改变 HTML 元素的内容.) (1)改变 HTML 输出流 在 JavaScript 中,docume ...

  8. js添加删除元素

    <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8& ...

  9. 使用Bootstrap + Vue.js实现 添加删除数据

    界面首先需要引入bootstrap的css和bootstrap的js文件,还有vue.js和jQuery.js才可以看见效果. 这里提供bootstrap的在线文件给大家引用: <!-- 最新版 ...

随机推荐

  1. 【Python】directory字典类型

    它的基本格式是(key是键,value是值): d = {key1 : value1, key2 : value2 } Example dir = {'Mic':1,'Sun':2} for k in ...

  2. [MFC]选择目录对话框和选择文件对话框

    在MFC编程中经常会需要用到选择目录和选择文件的界面,以下总结一下本人常用的这两种对话框的生成方法: 选择目录对话框 //选择目录按钮void CDcPackerDlg::OnBnClickedDec ...

  3. 一张图看懂CSS cascade, specific, importance, inheritance

    http://www.w3.org/TR/CSS21/cascade.html#inheritance http://www.w3.org/TR/CSS21/cascade.html#cascade ...

  4. Connection Manager ->> Multiple Flat File Connection & Multiple File Connection

    遍历一个文件夹下的所有文件的方法有两钟:1)使用Multiple Flat File Connection,把所有我们要的文件用"|"作为连接符拼凑出一条connection st ...

  5. glyphicons-halflings-regular.woff2 not found 前台错误修正

    错误内容如下: 首先在 web.config 里面加上如下内容: <system.webServer> <staticContent> <remove fileExten ...

  6. javascript小练手

    1.做一个小图标在界面中通过按钮可以变大 变小 变色 变圆 <!DOCTYPE html> <html lang="en"> <head> &l ...

  7. Access 64-bit HKLM\Software Registry by 32-bit C#.NET Application

    http://www.codeproject.com/Articles/1003177/Access-bit-HKLM-Software-Registry-by-bit-Csharp-NE While ...

  8. February 6 2017 Week 6 Monday

    There are no shortcuts to any place worth going. 任何值得去的地方,都没有捷径. Several years ago, I climbed the Hu ...

  9. C#中internal关键字

    对于一些大型的项目,通常由很多个DLL文件组成,引用了这些DLL,就能访问DLL里面的类和类里面的方法.比如,你写了一个记录日志的DLL,任何项目只要引用此DLL就能实现记录日志的功能,这个DLL文件 ...

  10. python进阶介绍(进阶1)

    转载请标明出处: http://www.cnblogs.com/why168888/p/6411664.html 本文出自:[Edwin博客园] python进阶介绍(进阶1) 1. python基础 ...