<template>
<div id="app">
<div class="demo">
<ul>
<template v-for="(v,index) in list">
<li>{{v.name}}</li>
<div v-show="!v.showMore">
<button @click="moreFun(index)">展示更多</button>
</div>
</template>
</ul>
</div>
</div>
</template>
<script>
export default {
name: 'app',
data() {
return {
list: [{
name: '小颖'
}, {
name: '仔仔'
}, {
name: '黑妞'
}, {
name: '土豆'
}]
}
},
methods: {
moreFun(index) {
console.log(this.list);
}
}
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
<div v-show="!v.showMore">
<button @click="moreFun(index)">展示更多</button>
</div>
moreFun(index) {
this.$set(this.list[index], 'showMore', true);
console.log(this.list);
}
<template>
<div id="app">
<div class="demo">
<ul>
<template v-for="(v,index) in list">
<li>{{v.name}}</li>
<div v-show="!v.showMore">
<button @click="moreFun(index)">展示更多</button>
</div>
</template>
</ul>
</div>
</div>
</template>
<script>
export default {
name: 'app',
data() {
return {
list: [{
name: '小颖'
}, {
name: '仔仔'
}, {
name: '黑妞'
}, {
name: '土豆'
}]
}
},
mounted: function() {
this.list.forEach(function(element, index) {
element.showMore = false;
});
},
methods: {
moreFun(index) {
this.list[index].showMore = true;
console.log(this.list);
}
}
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
<div v-show="!v.showMore"> <button @click="moreFun(index)">展示更多</button> </div>
<template>
<div id="app">
<div class="demo">
<input type="text" class="num1" v-model="num1">
<label class="sign">-</label>
<input type="text" class="num2" v-model="num2">
<label class="sign">=</label>
<label class="result">{{resultNum}}</label>
</div>
</div>
</template>
<script>
export default {
name: 'app',
data() {
return {
num1: 1,
num2: 5,
resultNum: null
}
},
watch: {
num1: function() {
var _num1 = parseInt(this.num1);
var _num2 = parseInt(this.num2);
this.resultNum = _num1 - _num2;
},
num2: function() {
var _num1 = parseInt(this.num1);
var _num2 = parseInt(this.num2);
this.resultNum = _num1 - _num2;
}
},
mounted: function() {
var _num1 = parseInt(this.num1);
var _num2 = parseInt(this.num2);
this.resultNum = _num1 - _num2;
}
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
input.num1,
input.num2 {
width: 100px;
}
label.sign {
font-size: 30px;
vertical-align: -3px;
}
label.result {
font-size: 20px;
}
</style>
<template>
<div id="app">
<div class="demo">
<ul>
<template v-for="(v,index) in list">
<li>{{v.name}}</li>
<li>{{v.age}}</li>
<button @click="deleteFun(index)">delete</button>
</template>
</ul>
</div>
</div>
</template>
<script>
export default {
name: 'app',
data() {
return {
list: [{
name: '小颖',
age:22
}, {
name: '仔仔',
age:1
}, {
name: '黑妞',
age:1
}, {
name: '土豆',
age:1
}]
}
},
methods: {
deleteFun(index) {
this.$delete(this.list[index], 'age');
}
}
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有