Vue.js实现简单的表格
Vue.js实现简单的表格1.代码如下<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X
·
Vue.js实现简单的表格
1.代码如下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<!--CSS样式外联link引入 -->
</head>
<body>
<div id ="app" align ="center">
<table border="2" >
<font>{{ message }}</font>
<tr>
<th v-for="th in title">{{th}} </th>
</tr>
<tr v-for = "people in data">
<td>{{people.id}}</td>
<td >{{people.name}}</td>
<td >{{people.age}}</td>
<td>{{people.sex}}</td>
</tr>
</table>
</div>
</body>
<style>
td{
text-align:center;
}
</style>
<script src="https://unpkg.com/vue/dist/vue.min.js"></script>
<script>
//创建Vue实例,得到 ViewModel
var app = new Vue({
el: '#app',
data: {
message:'学生信息',
title:['序号','姓名','年龄','性别'],
data:[{id:1,name:'李明', age:25,sex:'男'},
{id:2,name:'张曼玉',age:23,sex:'女'},
{id:3,name:'刘宏伟',age:28,sex:'男'},
{id:4,name:'小王',age:30,sex:'男'}
]
},/*数据*/
mounted(){},/*自动加载函数*/
methods: {},/*执行触发函数*/
computed: {},/*动态计算属性*/
});
</script>
</html>
2.效果图如下
更多推荐
所有评论(0)