账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    vue生命周期函数beforeUnmount内,如何及时异步发送axios请求?
    46
    0
    思路:这是个购物车跳转界面,当我点击结算的时候,路由跳转,页面经过beforeUnmount生命周期函数,但是由于异步的原因,经常跳转过去才接受到数据,导致结算页面无法渲染,希望各位大佬可以给一个解决思路内部代码如下beforeUnmount (){ //数据 const route = useRoute() const shopId = route.params.id const store = useStore() const cartList = store.state.cartList const products= cartList[shopId] const userinfo=JSON.parse(localStorage.userinfo) console.log(userinfo.id) //数据发送 const getContentData = async () =>{ const result = await request.post(`/api/v1/create`, { id:userinfo.id, addressId:1, shopId, shopName:"沃尔玛", products:JSON.stringify(products) }, ); console.log(result) } watchEffect(() => { getContentData() }) } }
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • ゅ文明人 普通会员 1楼
      502 Bad Gateway

      502 Bad Gateway


      nginx
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部