<script>
export default {
name: "Main2",
data() {
return {
musices:[]
}
},
created(){ //访问的控制层地址
this.axios.get("http://localhost:8080/selectmusicbytypeid").then(response=>(this.musices=response.data)) //传给musices
}
};
</script>
在<template>里写入
<el-table :data ="musices" > //对应上面的musices
<el-table-column prop="id" label="排名" width="50">
</el-table-column> //prop为数据库里的列
<el-table-column prop="musicname" label="歌曲" width="120">
</el-table-column>
<el-table-column prop="musicvolume" label="播放量" width="140">
</el-table-column>
<el-table-column prop="musicauthor" label="作者" width="140">
</el-table-column>
</el-table>
注意事项:1.更改端口
2.启动idea项目
3.下载组件axios