bind

bind方法生成了一個新的函數,稱爲綁定函數,傳入bind方法的第一個參數做爲這個綁定函數的this對象,傳入bind的第二個參數連同後面調用綁定函數時傳入的參數依照前後順序(傳入bind的在前)構成綁定函數的參數。 函數

   onClick:function(picker) {
           const date1 = new Date();
           const start = new Date().setMonth(0-12);
           const end = date1.setMonth(0-1);
            picker.$emit('pick', start);
            this.searchs.open_date[0]=start;
            this.searchs.open_date[1]=end;
         }.bind(this)

  將 全局的this 傳入,使得 this

this.searchs.open_date[0],this.searchs.open_date[1]能夠被正確賦值
相關文章
相關標籤/搜索