运行的时候,出现了php跨域问题,解决办法是在php的头文件中添加了如下代码:
header('Content-Type: application/json');
header('Content-Type: text/html;charset=utf-8');
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:*');
header('Access-Control-Allow-Headers:x-requested-with,content-type');
目的:在vue中获取从ajax获取的json数据,并用v-for循环显示在表格中
效果如下:
html示例代码如下:
Title}table{margin:100px auto;border:1px solid #000;border-collapse:collapse; /*设置表格的边框是否被合并为一个单一的边框*/border-spacing:0; /*设置相邻单元格的边框间的距离*/
}tr{width:300px;height:50px;line-height:50px;border-bottom:1px solid #000;background-color:pink;
}td, th{width:99px;height:50px;line-height:50px;text-align:center;border-right:1px solid #000;
}
姓名年龄住址