欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

vue 中promise 异步请求数据

程序员文章站 2023-10-15 19:10:48
组件中: getTypes('EP_TYPE').then((data) => {console.log('data',data)});//成功 ......
export function gettypes(type) {
    return listdictitems({ code: type }).then((res) => {
        if (res.code == 200) {
            let list = res.body;
            // console.log('list',list);
            return list;
        }
    })
};

组件中:

 gettypes('ep_type').then((data) => {console.log('data',data)});//成功