search

Home  >  Q&A  >  body text

javascript - The data will not be updated after the current page is liked. It will be updated after refreshing.

zan:function (n){
                        this.$http({
                            url:URL,
                            data:{
                                act:'acc',
                                id:n
                            }
                        }).then(function(res){
                                 //这里怎么写,大胸弟....
                        });

                    },

某草草某草草2869 days ago502

reply all(4)I'll reply

  • PHP中文网

    PHP中文网2017-05-19 10:18:01

    After clicking, it’s not enough to change the displayed number. The variable used is the variable number + 1

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-19 10:18:01

    After the click event, add one to the number and then change the displayed number on the page. Either you write less or there is something wrong with the order of your writing

    reply
    0
  • 天蓬老师

    天蓬老师2017-05-19 10:18:01

    After clicking, send a like request through ajax. If the request is successful, the number of likes will be updated. If the request fails, "Like Failed" will be displayed and the number will remain unchanged.

    reply
    0
  • PHP中文网

    PHP中文网2017-05-19 10:18:01

    zan:function (n){
                            this.$http({
                                url:URL,
                                data:{
                                    act:'acc',
                                    id:n
                                }
                            }).then(function(res){
                                     //这里怎么写,大胸弟....
                                     if(res.status === xx){
    // vm.num  你绑定的数据 直接赋值                                  vm.num = res.data
                                     }
                            });
    
                        }

    reply
    0
  • Cancelreply