鍍金池/ 問答/Java  HTML/ 在iview中ajax返回值如何賦值上層變量?

在iview中ajax返回值如何賦值上層變量?

        authorlist: 1
    },
    methods: {
        handleSearchauthor: function(value) {
                    $.ajax({  
                       url : 'post1.php',  
                       type : 'post',  
                       data : value,  
                       success : function(data) { 
                       在這個地方,我怎么把data賦給authorlist呢?
回答
編輯回答
爛人

箭頭函數(shù)

        authorlist: 1
    },
    methods: {
        handleSearchauthor: function(value) {
                    $.ajax({  
                       url : 'post1.php',  
                       type : 'post',  
                       data : value,  
                       success : (data) => { 
                           this.authorlist = data
2017年10月15日 12:33
編輯回答
別逞強(qiáng)

`authorlist: 1

},
methods: {
    handleSearchauthor: function(value) {
                var   _self   =   this
                $.ajax({  
                   url : 'post1.php',  
                   type : 'post',  
                   data : value,  
                   success : function(data) { 
                     _self.authorlist  =  data
                  }

`
self.屬性名 指向?qū)嵗臄?shù)據(jù)

2018年1月26日 14:37
編輯回答
囍槑
handleSearchauthor: function (value) {
    let self = this;
    $.ajax({
        ...,
        success: function (data) {
            self.authorlist = data;
        }
    })
}
2017年11月10日 14:03