雪莉酱
<table id="testTable"> <tr v-for="(el, lineIndex) in lines" v-line-inserted="lineIndex" > <td> <input name="bindSelect2" /> <td> </tr></table>function renderLines(el, lineIndex){ //渲染select2 $("testTable tr").eq(lineIndex).select2({...});}Vue.directive('line-inserted', { inserted: function (el, binding) { var lineIndex = binding.value; renderLines(el, lineIndex); }});