assistants

1、安装vue-resource到项目中,找到当前项目

输入:npm install vue-resource --save

 

2、安装完毕后,在main.js中导入,如下所示:

import  VueResource  from \'vue-resource\'

Vue.use(VueResource) 

 

//页面加载之前 使用钩子函数 获取内容
created() {
this.$http.get("http://jsonplaceholder.typicode.com/todos")
.then((data) => {
this.arrs = data.body;
}),
this.$http.get("https://api.apiopen.top/EmailSearch?number=1012002").then((data) => {
this.arr = data.body;
})
}

 

PS:

main.js 加上

Vue.http.options.root = \'http://jsonplaceholder.typicode.com\';

 

将页面的created(){}改为:

created() {
this.$http.get("todos")
.then((data) => {
this.arrs = data.body;
})

 

分类:

技术点:

相关文章:

  • 2021-11-05
  • 2021-10-05
  • 2022-12-23
  • 2022-01-20
  • 2021-11-21
  • 2022-01-07
  • 2021-11-21
猜你喜欢
  • 2021-11-21
  • 2022-12-23
  • 2021-11-21
  • 2021-11-21
  • 2021-12-14
  • 2021-11-06
  • 2021-11-21
相关资源
相似解决方案