vue & lifecycle methods & this bug


ES6 Arrow function & this bind bug

bad

fetchTableData: (url = ``, options = {}) => {}


// arrow function & this bind bug!
// fetchTableData: (url = ``, options = {}) => {
fetchTableData (url = ``, options = {}) {
// fetchTableData
// return Promise && async await
// let url = "http://10.1.5.202/es6-test/axios/preview-user.new.json";
if (!url) {
url = "http://10.1.5.202/es6-test/axios/preview-user.new.json";
}
let that = this;
console.log(`this =`, this);
console.log(`that =`, that);
// console.log(`this.a.data =`, this.a.data);
// Axios.post(url, options)
Axios.get(url)
.then((res) => {
let {
data: json
} = res;
if (json.data.length) {
// that.a.data.totalPage = json.data.length;
// that.a.data.allDatas = json.data;
// // pagination
// that.a.data.table = that.a.methods.getPaginationData(that.a.data.allDatas, that.a.data.currentPage, that.a.data.pageSize);
// that.$data.totalPage = json.data.length;
// that.$data.allDatas = json.data;
// // pagination
// that.$data.table = that.getPaginationData(that.$data.allDatas, that.$data.currentPage, that.$data.pageSize);
this.$data.totalPage = json.data.length;
this.$data.allDatas = json.data;
// pagination
this.$data.table = this.getPaginationData(this.$data.allDatas, this.$data.currentPage, this.$data.pageSize);
}
});
},

ES6 & class methods

OK

    showInitTableData(url = ``) {
console.log(`init this =`, this);
Axios.get(url)
.then((res) => {
let {
data: json
} = res;
if (json.data.length) {
this.$data.totalPage = json.data.length;
this.$data.allDatas = json.data;
// pagination
this.$data.table = this.getPaginationData(this.$data.allDatas, this.$data.currentPage, this.$data.pageSize);
}
});
},

vue & lifecycle methods & this bug & ES6 Arrow function & this bind bug的更多相关文章

  1. ES6 Arrow Function & this bug

    ES6 Arrow Function & this bug let accHeadings = document.querySelectorAll(`.accordionItemHeading ...

  2. ES6 Arrow Function All In One

    ES6 Arrow Function All In One this const log = console.log; const arrow_func = (args) => log(`arg ...

  3. ES6 arrow function vs ES5 function

    ES6 arrow function vs ES5 function ES6 arrow function 与 ES5 function 区别 this refs xgqfrms 2012-2020 ...

  4. ES6 Arrow Function return Object

    ES6 Arrow Function return Object https://github.com/lydiahallie/javascript-questions/issues/220#issu ...

  5. arrow function and bind

    Can you bind arrow functions? https://stackoverflow.com/questions/33308121/can-you-bind-arrow-functi ...

  6. ES6 arrow function

    语法: () => { … } // 零个参数用 () 表示: x => { … } // 一个参数可以省略 (): (x, y) => { … } // 多参数不能省略 (): 当 ...

  7. [ES6] 06. Arrow Function =>

    ES6 arrow function is somehow like CoffeeScirpt. CoffeeScript: //function call coffee = -> coffee ...

  8. js arrow function return object

    js arrow function return object bug filterData: { type: Object, default: () => {}, required: true ...

  9. bind & this & new & arrow function

    bind & this & new & arrow function this bind call apply new arrow function arrow functio ...

随机推荐

  1. 使用nssm将bat文件注册为windows service (eg:solr, nodejs)

    nssm下载:http://pan.baidu.com/s/1sjAEevj _install.bat @echo off Set BasePath=D:\Tools %BasePath%\nssm- ...

  2. 自学youku_web

    仿youku架构 数据库设计 管理员 注册 登录 上传视频 删除视频 发布公告 普通用户 注册 登录 充会员 查看视频 下载免费视频 下载收费视频 查看观影记录 查看公告 思路 class Field ...

  3. Objective-c 单例设计模式

    Objective-c 单例设计模式 一.什么是单例模式:(Singleton)      单例模式的意图是是的类的对象成为系统中唯一的实例,提供一个访问点,供客户类共享资源.   二.什么情况下使用 ...

  4. 使用android ndk编译x86 so在linux下使用的问题

    一直以为android ndk编译x86 so库可以在linxu下运行,结果我试了几次都行不通.后来想了一下,android ndk编译的库应该只能在android设备或模拟器上运行才有效,后来改用 ...

  5. 字符串替换For linux C

    1.临时空间给了个1024,不需要可减少长度. 2.结果只用用strcpy了,没校验. bool Replace(char *str,const char *src, const char *des) ...

  6. PLC状态机编程第二篇-负载均衡

    控制任务 大家好,今天我们用状态机描述稍复杂的实例,同时用LAD和ST语言写状态机.我们的控制任务如下: 真空泵A和真空泵B, 按下启动按钮后, 泵A启动, 3秒后泵B也启动, 此时泵A仍运行, 当容 ...

  7. Pandas 数据读取

    1.读取table # 读取普通分隔数据:read_table # 可以读取txt,csv import os os.chdir('F:/') #首先设置一下读取的路径 data1 = pd.read ...

  8. 使用postMan测试insert或者update接口

    URL : http://localhost:8099/orderVoice/updateAgentLogin?access_token=7f10e803-f886-47df-b3dc-9ed307d ...

  9. [Codeforces958A2]Death Stars (medium)(字符串+hash)

    Description 题目链接 Solution 这里用类似hash的方法将判断2个矩阵是否相同的时间降为O(m),总时间复杂度为O(m3) Code #include <cstdio> ...

  10. 15、python之导入模块

    一.什么是模块? 模块本质是一个py文件,我们可以通过关键字import将py文件对象导入到当前名称空间. 二.导入模块 1.import module 2.from module import ob ...