我希望将此标记克隆为该月中某一天的次数:
<td class="day noclass" v-on:click="workedDay" :class="{ active: isActive }"></td>
我试过了:
let tdCells;
for ( let j = 1; j <= this.nbDaysInMonth; j++)
{
tdCells = document.createElement("td");
tdCells.setAttribute("class", "dayOfMonth");
tdCells.setAttribute(":class", "{ active: isActive }");
tdCells.setAttribute("v-on:click", "workedDay");
document.getElementsByClassName('cells')[0].appendChild(tdCells);
}
但它创建了html属性但不能用于VueJs
答案 0 :(得分:1)
您可以使用v-for循环对象
<tr v-for="day in nbDaysInMonth">
<td class="day noclass" v-on:click="workedDay" :class="{ active: isActive }"></td>
</tr>