网易实时新闻Api说明文档
实时热点新闻列表 20条
| 地址 | 方式 |
|---|
https://api.xiaohuwei.cn/news.php | GET |
传递参数说明
PS:type 参数可为 hot(精选)yule (娱乐) toutiao (头条)motion (运动) 不传默认为 hot
返回数据说明
| 参数名 | 说明 |
|---|
docid | 每篇新闻唯一标识ID 可用来获取新闻详情 |
Vue请求新闻实例
Vue.prototype.gethome = params => { //main.js //挂载到全局
return axios.get(`http://api.xiaohuwei.cn/news.php?type=yule`, params)
.then(res => res.data)
};
//全局调用
mounted(){
this.fn();
},
methods: {
fn(ids){
fn(){
this.gethome()
.then(res=>{this.arr=res;})//api.js里面挂载到原型的方法
},
},
},
新闻详情Api
| 地址 | 方式 |
|---|
https://api.xiaohuwei.cn/memeda.php | GET |
传递参数
| 参数 | 说明 | 类型 | 选择性 |
|---|
id | 新闻唯一ID | String | 必传 |
Vue请求文章详情实例
//main.js 定义函数
Vue.prototype.news = can =>{
return axios.get(`http://api.xiaohuwei.cn/memeda.php`, {params:can})
.then(res => res.data)
};
//全局调用
mounted(){
this.fn(this.$route.params.id);//接收新闻唯一ID
},
methods: {
fn(ids){
const can = {
id:ids
};
this.news(can).then(res=>{this.arr=res;})//调用方法
},
},
肖虎威博客?
能给个详情页获取的api吗这样也减少下你服务器的压力
强大,不用付费的吧?
调用频率呢?
免费,频率随缘~
咦,好东西,你的博客自己不用呀~~
@(滑稽)还没有~