組件的myProp屬性是一個(gè)函數(shù)func搓幌,這時(shí)想給func傳入一個(gè)參數(shù)如idx
<template v-for="(col, idx) in columns">
<Child :myProp="func"/> //這兒需要把idx傳給func
</template>
可這樣實(shí)現(xiàn):
<template v-for="(col, idx) in columns">
<Child :myProp="func(idx)"/>
</template>
<script>
func(idx){
return (params) => {
console.log(params, idx)
}
}
</script>