javascript - viewport 不是 .js 中的函数错误
问题描述
我是 javascript 的新手,我有以下错误“未捕获的 TypeError:视口不是函数 scripts.min.js:279”,我不明白如何修复它。知道有什么问题吗?谢谢。
var lastScrollTop = 0;
function smartSidebars() { //<==== line 279
var width = viewport().width;
var st = jQuery(window).scrollTop();
//see which direction we're going
if (st > lastScrollTop){
var direction = 'down';
} else {
var direction = 'up';
}
affixObject(jQuery('.post-left'), jQuery('.post-right'), direction, false);
if(width > 991) {
affixObject(jQuery('.loop-sidebar-left'), jQuery('.main-post-container'), direction, true);
affixObject(jQuery('.loop-sidebar-right'), jQuery('.main-post-container'), direction, true);
affixObject(jQuery('.single-sidebar'), jQuery('.post-right'), direction, true);
} else {
moveLoop();
}
lastScrollTop = st;
}
//-----------------------------------------------------------
function viewport() {
var e = window, a = 'inner';
if (!('innerWidth' in window )) {
a = 'client';
e = document.documentElement || document.body;
}
return { width : e[ a+'Width' ] , height : e[ a+'Height' ] };
}
解决方案
推荐阅读
- arrays - Express 返回空数组,但数组没问题
- python - 如何将数据帧的每个第 i 个元素映射到来自 PySpark 中范围定义的另一个数据帧的键
- vim - 在 zsh 终端中使用 vim 键,如何退出“excute:_”模式?
- dialogflow-es - AOG中文版:有时会出现Invocation Error?AOG不稳定?
- active-directory - Keytab 文件认证检查
- android - Fetch API 无法加载 file:///****。不支持 URL 方案“文件”。WebView 安卓
- node.js - 如何在 azure 虚拟机中永久运行节点服务器?
- bitbucket - git push 在 bitbucket 存储库上不起作用
- yocto - 使用 Yocto Dunfell 在启动时运行应用程序
- android - 在 ScrollView 内部的 GridLayout 之前添加空间