vue & lifecycle methods & this bug & ES6 Arrow function & this bind bug
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的更多相关文章
- ES6 Arrow Function & this bug
ES6 Arrow Function & this bug let accHeadings = document.querySelectorAll(`.accordionItemHeading ...
- ES6 Arrow Function All In One
ES6 Arrow Function All In One this const log = console.log; const arrow_func = (args) => log(`arg ...
- ES6 arrow function vs ES5 function
ES6 arrow function vs ES5 function ES6 arrow function 与 ES5 function 区别 this refs xgqfrms 2012-2020 ...
- ES6 Arrow Function return Object
ES6 Arrow Function return Object https://github.com/lydiahallie/javascript-questions/issues/220#issu ...
- arrow function and bind
Can you bind arrow functions? https://stackoverflow.com/questions/33308121/can-you-bind-arrow-functi ...
- ES6 arrow function
语法: () => { … } // 零个参数用 () 表示: x => { … } // 一个参数可以省略 (): (x, y) => { … } // 多参数不能省略 (): 当 ...
- [ES6] 06. Arrow Function =>
ES6 arrow function is somehow like CoffeeScirpt. CoffeeScript: //function call coffee = -> coffee ...
- js arrow function return object
js arrow function return object bug filterData: { type: Object, default: () => {}, required: true ...
- bind & this & new & arrow function
bind & this & new & arrow function this bind call apply new arrow function arrow functio ...
随机推荐
- 搭建大众点评CAT监控平台
CAT(Central Application Tracking)是基于Java开发的实时应用监控平台,包括实时应用监控,业务监控.关于CAT的具体介绍可移步到CAT官网进行查阅. 1. 环境清单 C ...
- SVN中trunk,branches,tags用法详解(转载)
转载出处:http://www.cnblogs.com/dafozhang/archive/2012/06/28/2567769.html Subversion是一个自由开源的版本控制系统.在Subv ...
- git分布式版本控制系统常用的操作
Git是一个版本控制系统,用来追踪计算机文件的变化的工具,也是一个供多人使用的协同工具.它是一个分布式的版本控制系统,本文将简单介绍如何使用.简单来说,就是你要和你的伙伴一起完成一项任务,但是你们要互 ...
- <Docker学习>6. docker使用网络
在容器中部署一个web应用,外部如何访问? 容器与容器间如何访问? 外部访问容器 容器可以运行一些网络应用,让外部也可以访问的话,需要进行服务器和容器的端口映射 -p 或者 -P -P默认会分配一个4 ...
- Reward HDU - 2647
传送门 Dandelion's uncle is a boss of a factory. As the spring festival is coming , he wants to dis ...
- 笔记-pytho-语法-yield
笔记-python-语法-yield 1. yield 1.1. yield基本使用 def fab(max): n,a,b = 0, 0, 1 while n < max: y ...
- wlr快捷键
ref:http://www.cnblogs.com/zhangyang/archive/2011/07/22/2113856.html Windows Live Writer提供了许多方便的快捷 ...
- PHP代码审计5-实战漏洞挖掘-cms后台登录绕过
cms后台登录绕过 练习源码:[来源:源码下载](数据库配置信息有误,interesting) 注:需进行安装 1.创建数据库 2.设置账号密码,连接数据库 3.1 正常登录后台,抓包分析数据提交位置 ...
- P3817 小A的糖果(洛谷月赛)
P3817 小A的糖果 题目描述 小A有N个糖果盒,第i个盒中有a[i]颗糖果. 小A每次可以从其中一盒糖果中吃掉一颗,他想知道,要让任意两个相邻的盒子中加起来都只有x颗或以下的糖果,至少得吃掉几颗糖 ...
- JavaScript获取时间
var myDate = new Date(); console.log(myDate.getFullYear()); //获取完整的年份(4位,1970-????) ...