Skip to content

Instantly share code, notes, and snippets.

@bushuai
Created August 20, 2016 13:42
Show Gist options
  • Save bushuai/36db796d411a76d6d468becb9770bac4 to your computer and use it in GitHub Desktop.
Save bushuai/36db796d411a76d6d468becb9770bac4 to your computer and use it in GitHub Desktop.

vue relateds

@bushuai
Copy link
Author

bushuai commented Aug 20, 2016

@bushuai
Copy link
Author

bushuai commented Aug 20, 2016

@bushuai
Copy link
Author

bushuai commented Aug 20, 2016

@bushuai
Copy link
Author

bushuai commented Aug 20, 2016

@bushuai
Copy link
Author

bushuai commented Aug 20, 2016

@bushuai
Copy link
Author

bushuai commented Aug 20, 2016

@bushuai
Copy link
Author

bushuai commented Aug 20, 2016

@bushuai
Copy link
Author

bushuai commented Aug 20, 2016

@bushuai
Copy link
Author

bushuai commented Aug 20, 2016

@bushuai
Copy link
Author

bushuai commented Dec 26, 2016

Q: Failed to mount component: template or render function not defined. (found in root instance) #713
A: vuejs/vue-router#713

@bushuai
Copy link
Author

bushuai commented Oct 23, 2018

/**
@description 页面垂直平滑滚动到指定滚动高度
@author zhangxinxu(.com)
*/
var scrollSmoothTo = function (position) {
if (!window.requestAnimationFrame) {
window.requestAnimationFrame = function(callback, element) {
return setTimeout(callback, 17);
};
}
// 当前滚动高度
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
// 滚动step方法
var step = function () {
// 距离目标滚动距离
var distance = position - scrollTop;
// 目标滚动位置
scrollTop = scrollTop + distance / 5;
if (Math.abs(distance) < 1) {
window.scrollTo(0, position);
} else {
window.scrollTo(0, scrollTop);
requestAnimationFrame(step);
}
};
step();
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment