无数据代码为
<script>
new Vue({
el:"#demo",
data:{list:find()}
})
function find(){
var ss;
$.ajax({
type: "post",
url: "studentaction.action?methodName=findallStudent",
dataType: "json",
success: function(msg){
ss=msg;
console.log(msg)
}
})
return ss;
}
</script>
<table id="demo" lay-filter="test">
<tr v-for="item in list" :key="item.id">
<td>{{item.name}}</td>
</tr>
</table>
我们可以看到右下角数据是已经加载出来了的,但是页面上却没有显示
我们至于要加入一行代码 async: false,让ajax先执行即可
function find(){
var ss;
$.ajax({
type: "post",
url: "studentaction.action?methodName=findallStudent",
dataType: "json",
async: false,//让ajax先执行
success: function(msg){
ss=msg;
console.log(msg)
}
})
return ss;
}