<template>
<div>
<button @click="add">添加</button>
<table>
<tr>
<th>id</th>
<th>学号</th>
<th>姓名</th>
<th>操作</th>
</tr>
<tr v-for="item in items" :key="item">
<td>{{ item.stuid }}</td>
<td>{{ item.stuno }}</td>
<td>{{ item.stuname }}</td>
<td><button @click(item.stuid)="dele">删除</button></td>
</tr>
</table>
</div>
</template>
a
<script>
export default {
data() {
return {
name: "",
errormsg: "",
token: "",
items: []
}
},
mounted: function () {
this.list();
},
methods: {
list() {
var token = this.$route.query.token;
this.token = token
this.axios.get("http://114.67.241.121:8088/stu/list", {
headers: {
'Authorization': token
}
}).then(res => {
console.log(res)
this.items = res.data.data
})
},
dele(id){
this.axios.post("http://114.67.241.121:8088/stu/del", {
headers: {
'Authorization': token
},params:{
stuid:id
}
}).then(res => {
console.log(res)
})
},
add(){
this.$router.push(
{
path: 'add',
query: { token: this.token }
})
}
},
}
</script>
<style scoped>
table, th, td
table{
font-family: verdana,arial,sans-serif;
font-size:11px;
border-width: 1px;
border-collapse: collapse;
}
table th {
border-width: 1px;
padding: 8px;
border-style: solid;
}
table td {
border-width: 1px;
padding: 8px;
border-style: solid;
}
</style>