VueMusic-2.今日推荐-数据获取

1.redirect:'/Home'(重定向);

2.安装npm install --save axios

3.配置axios的

import Axios from 'axios'
Vue.prototype.$axios=Axios

4.跨域处理:

proxyTable:{
"/baidu_music_api": {
target: "http://tingapi.ting.baidu.com",
changeOrigin: true,
pathRewrite: {
'^/baidu_music_api': ''
}
}
}

Vue.prototype.HOST="/baidu_music_api"

5.实例:

<template>
<div>今日推荐</div>
</template>

<script>
export default{
name:"todayRecommend",
data(){
return{

}
},
mounted(){
var url=this.HOST+"/v1/restserver/ting?method=baidu.ting.billboard.billList&type=1&size=6&offset=0"
this.$axios.get(url)
.then(res => {
console.log(res)
}).catch(error => {
console.log(error)
}
)
}
}
</script>

<style scoped>
.mod-albums {
background-color: #fff;
padding: 10px 17px;
}

.hd {
display: flex;
margin: 14px 0 18px 0;
}

.hd h2 {
-webkit-box-flex: 1;
-webkit-flex: 1;
flex: 1;
margin: 0;
padding: 0;
font-size: 20px;
}

.hd div {
width: 64px;
font-size: 12px;
text-align: right;
}

.mod-albums .gallery {
overflow: hidden;
margin: 0 -5px;
}

.mod-albums .gallery .card {
width: 33.3%;
float: left;
-webkit-box-sizing: border-box;
box-sizing: border-box;
padding: 0 5px 10px;
}

.mod-albums .gallery .card .album {
position: relative;
}

.mod-albums .gallery .card img {
width: 100%;
height: auto;
border: 1px solid #eee;
}

.mod-albums .gallery .card .name {
font-size: 12px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
margin-top: 4px;
line-height: 14px;
max-height: 28px;
margin-bottom: 2px;
}
</style>

转载于:https://www.cnblogs.com/xiao-peng-ji/p/11409528.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值