<template>
<view>
<view v-for="(item,index) in contentList" :key="index" @click="getMethods(item.methods)">{{item.title}}</view>
</view>
</template>
<script>
export default {
data() {
return {
contentList: [{
title: '方法1',
methods: 'methodsOne'
},
{
title: '方法2',
methods: 'methodsTwo'
},
{
title: '方法3',
methods: 'methodsthree'
}
]
}
},
methods: {
getMethods(methodWay) {
this[methodWay]();
},
methodsOne() {
console.log("methodsOne")
},
methodsTwo() {
console.log("methodsTwo")
},
methodsthree() {
console.log("methodsthree")
},
}
}
</script>
<style lang="scss">
</style>
v-for循环渲染 执行方法 相对应方法
最新推荐文章于 2023-03-11 11:46:13 发布