<tr v-for="item in items"> <td>{{ item.UserID }}</td> <td>{{ item.UserName }}</td> <td>{{ item.LoginName }}</td> <td>{{ item.Password }}</td> <td>{{ item.Email }}</td> <td>{{ item.Tell }}</td> <td v-if="item.Sex==1">男</td> <td v-else>女</td> @foreach (var item2 in UserRole) { <td v-if="@item2.RoleID==item.RoleID">@item2.RoleName</td> } <td class="operation"> <a v-bind:href="'UserEdit?LoginName='+item.LoginName" >编辑</a> <a href="javascript:;" onclick="doDelete(this)" v-bind:data-id="item.UserID" v-bind:data-name="item.UserName" v-bind:data-loginname="item.LoginName">删除</a> </td> </tr>
如上代码,使用vue.js的v-if后网页显示:
jquery.dataTables.js:6122 Uncaught TypeError: Cannot read property 'mData' of undefined,求大神解惑
<!DOCTYPE html> <html> <head> <script src="https://unpkg.com/vue/dist/vue.js"></script> <meta charset="utf-8"/> <title></title> </head> <body> <table id="app2"> <tr v-for="item in items"> <td>{{ item.UserID }}</td> <td>{{ item.UserName }}</td> <td v-if="item.Sex==1">男</td> <td v-else>女</td> </tr> </table> </body> <script> var itemss = [ { UserID: 1, UserName: "aa", Sex: 1 }, { UserID: 1, UserName: "bb", Sex: 2 } ]; var app = new Vue({ el: '#app2', data: { items: itemss } }); </script> </html>
没有发现问题!
看懂标题