bootstrap+vue+axios+json格式

快捷键

.container>.row.text-center>h1{用户数据}
<div class="container">
	<div class="row text-center">
		<h1>用户数据</h1>
	</div>
</div>
.row>.col-xs-offset-3.col-xs-6>table.table.table-striped.table-bordered.table-hover>(tr>th*3)+(tr>td*3)
<div class="row">
	<div class="col-xs-offset-3 col-xs-6">
		<table class="table table-striped table-bordered table-hover">
			<tr>
				<th></th>
				<th></th>
				<th></th>
			</tr>
			<tr>
				<td></td>
				<td></td>
				<td></td>
			</tr>
		</table>
	</div>
</div>

index.html

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="lib/bootstrap/css/bootstrap.min.css"/>
	</head>
	<body>
		<div class="container">
			<div class="row text-center">
				<h1>{{title}}</h1>
			</div>
			<div class="row">
				<div class="col-xs-offset-3 col-xs-6">
					<table class="table table-striped table-bordered table-hover">
						<tr>
							<th>id</th>
							<th>姓名</th>
							<th>生日</th>
						</tr>
						<tr v-for="employee in tabs">
							<td>{{employee.employeeId}}</td>
							<td>{{employee.employeeNo}}</td>
							<td>{{employee.birthday}}</td>
						</tr>
					</table>
				</div>
			</div>
		</div>
		<script src="lib/vue/vue.min.js" type="application/javascript"></script>
		<script src="lib/vue/axios.min.js" type="application/javascript"></script>
		<script src="js/index.js" type="application/javascript"></script>
	</body>
</html>

index.js

/*自执行函数,又称封包自执行函数,相当于java中的包
 * 特点:别的js访问不到其中的内容,防止全局污染*/
;(function(){
	var vue=new Vue({
		/*el代表在页面上找到这个元素,被vue做成模板,参与编译*/
		el:'.container',
		/*双向绑定*/
		data:{
			title:'hello,vue',
			/*tabs:[{"userId":"1","userName":"张三","birthday":"2019-10-10"},
				{"userId":"2","userName":"李四","birthday":"2019-10-11"},
			]*/
			tabs:[]
		},
		/*vue对象创建好的一瞬间,初始化钩子*/
		created:function(){
			axios.get('http://localhost:9000/init')
				.then(function(res){
					vue.$data.tabs=res.data;
				})
		}
	});
})();

猜你喜欢

转载自blog.csdn.net/qq_39905910/article/details/84324168
今日推荐