控制台报错vue.runtime.esm.js [Vue warn]: Error in created hook: “TypeError: Object(...) is not a function

页面内调用接口控制台报错

vue.runtime.esm.js?2b0e:4605 [Vue warn]: Error in created hook: “TypeError: Object(…) is not a function”

原因

因为是api.js中没有导出正确的方法

export function postAddReq(params) {
    
    
  return request({
    
    
    url: postAddApi,
    method: "post",
    params,
  });
}

可能是因为在页面中没有引入方法,而是引入了自己定义的url路径导致报错,应该在页面里面引入定义导出的接口方法

import {
    
     postAddReq} from "@api";

猜你喜欢

转载自blog.csdn.net/Xiang_Gong_Ya_/article/details/131658375