axios方法

  1. getmovie:function () {
  2. var that = this;
  3. axios.get("https://douban.uieee.com/v2/movie/top250")
  4. .then(function (response) {
  5. var arr=response.data.subjects;
  6. console.log('arr', arr);
  7. let titleList = arr.map((item, index)=>{
  8. return item.title;/*-------map方法---------*/
  9. })
  10. that.movie=titleList;
  11. console.log(titleList);
  12. },function (err) {
  13. })
  14. }
  15. }

map遍历方法

map() 方法返回一个新数组,数组中的元素为原始数组元素调用函数处理后的值。
map() 方法按照原始数组元素顺序依次处理元素。
写法(1)let a=数组.map((item,index)=>{
return item.要获取的属性
})
写法(2)**array.map(function(currentValue,index,arr), thisValue)
image.png**