有没有办法从参数中传递函数名?
像这样的..
<tr v-for="item in items" class="static"
v-bind:class="{'evenRow': item.oddeven=='1', 'oddRow': item.oddeven=='0' }"
@click="item.click(item.contactID)" >
</tr>
项目在呈现页面时,click不会转换为相应的函数.
有没有办法从参数中传递函数名?
像这样的..
<tr v-for="item in items" class="static"
v-bind:class="{'evenRow': item.oddeven=='1', 'oddRow': item.oddeven=='0' }"
@click="item.click(item.contactID)" >
</tr>
项目在呈现页面时,click不会转换为相应的函数.
要使用动态函数调用,建议使用一个助手函数来接收函数名并调用相应的函数.
handle_function_call(function_name) {
this[function_name]()
},
在模板中,当迭代项时,可以通过传递函数名来调用该函数,如
<button v-for="button of items"
:key="button.id"
@click="handle_function_call(button.fn_name)" //=> note here
>
{{ button.text }}
</button>
看《行动in jsfiddle》