基于vue框架以及网易云API实现的小项目

技术方案

github 地址: https://github.com/ljlhnick/vue-wangyiyun 喜欢欢迎点个 start,支持下我
技术方案:vue+vue-router+axios+typeScript+element-ui+vue-property-decorator(class 方式写组件)

模块划分

歌单列表,歌单,分页,播放详情,个人资料提交

代码 class 编程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<script lang="ts">
import { formatDate } from "./date.js";
import TableList from "../tableList.vue";
import axios from "axios";
import { Vue, Component, Watch } from "vue-property-decorator";
@Component({
components: {
TableList
},
filters: {
formatDate(time: Date) {
const date = new Date(time);
return formatDate(date, "yyyy-MM-dd");
}
}
})
export default class SongFirst extends Vue {
subdesc = "";
sheepList = [];
totalCount = 0;
currentPage = 1;

created() {
this.get();
}

get() {
if (typeof this.$route.query.songId === "undefined") {
return;
}
axios({
url: "https://api.imjad.cn/cloudmusic/",
method: "get",
params: {
type: "playlist",
id: this.$route.query.songId,
offest: this.currentPage - 1
}
}).then(res => {
this.subdesc = res.data.playlist;
this.sheepList = res.data.playlist.tracks;
this.totalCount = res.data.playlist.trackCount;
});
}

changePage(currentPage: number) {
this.currentPage = currentPage;
this.get();
}

@Watch("$route", { immediate: false, deep: false })
pageChange() {
this.get();
}
}
</script>

功能图

主页
主页
歌单
歌单
播放详情
播放详情
我的(表单验证)
表单验证

ljlhnick wechat
subscribe to my blog by scanning my public wechat account
Donate comment here