工作记录
代码:
<template>
<div id="container">
<button class="demo" v-for="(item,itemKey) in itemList" :key="itemKey" @click="itemFun(item)">{{itemKey}}</button>
</div>
</template>
<script>
export default {
name: 'Home',
data() {
return {
itemList:[
{
isFun:true,
function_name:'first_fun'
},
{
isFun:false,
function_name:'second_fun'
},
{
isFun:true,
function_name:'third_fun'
},
]
}
},
methods: {
itemFun(item){
if (item.isFun){
this[item.function_name]();
}
},
first_fun(){
console.log('first_fun')
},
third_fun(){
console.log('third_fun')
}
},
mounted() {
}
}
</script>
<style>
.demo{
width: 50px;
height: 50px;
}
</style>
|