hanjc1993 / studynote Goto Github PK
View Code? Open in Web Editor NEW单纯的学习笔记
单纯的学习笔记
1、小程序wxml中不能使用变量作为属性名,下面这个是不合法的
{{hehe[item.shuxing]}}
2、
github的issues使用markdown特有语法,原文https://blog.csdn.net/mint_ying/article/details/82747314
和https://www.cnblogs.com/yabin/p/6366151.html
概念问题,都很简单
节流:延迟一段时间才放开,一般用于高发事件比如鼠标滑动、页面滚动等
let cantUse = false
someEvent(()=>{
if(cantUse) return
//do something
cantUse = true
setTimeout(()=>{
cantUse = false
},200)
})
防抖:每次事件触发后先清空上一个延迟函数并启动下一个延迟函数,最终执行的内容放在延迟函数中
let timeOut = null
someEvent(()=>{
clearTimeout(timeOut)
timeOut = setTimeout(()=>{
//do something
},200)
以下在原文基础上进行修改
VSCode安装过程中忘了勾选添加到右键菜单的选项,或者重装vscode导致之前的配置失效,可采取以下办法解决
Win+R 打开运行,输入regedit,打开注册表,找到HKEY_CLASSES_ROOT*\shell分支,如果没有shell分支,则在*下点击右键,选择“新建-项”,建立shell分支。
在shell下新建“VisualCode”项,在右侧窗口的“默认”键值栏内输入“open with visual code”,这是单击鼠标右键时VisualCode启动程序的显示值。项的名称和键值可以任意,以含义明确为好。其中键值将显示在右键菜单中。
在“VisualCode”下再新建Command项,在右侧窗口的“默认”键值栏内输入记事本程序所在的路径,我的是:"D:\Program Files (x86)\Microsoft VS Code\code.exe" "%1"。其中的%1表示要打开的文件参数。也就是Visual Code启动程序,找不到的话就在开始里面查找Visual Studio Code,再右键打开文件位置
关闭注册表,即可生效。
以上方法可以在选中文件时右键在菜单栏中显示:"open with visual code",但当右键文件夹时仍然不能显示此选项,所以还要进行下面的操作:
打开注册表,找到HKEY_CLASSES_ROOT\Directory\shell和HKEY_CLASSES_ROOT\Directory\background\shell,按照上面2、3的方法添加即可。
在原有的项上新建可扩充字符串值,命名为Icon,像一个键值对那样把D:\Program Files (x86)\Microsoft VS Code\code.exe放进去就可以了。
当更新程序或者是卸载Visual code时直接找到注册表中的相应位置修改或删除即可。
顺便说一下360安全卫士的右键绑定删除:找到“HKEY_CLASSES_ROOT*\shellex\ContextMenuHandlers”;如果是只对文件夹有效的项目,则存放在
“HKEY_CLASSES_ROOT\Directory\shell”
“HKEY_CLASSES_ROOT\Directory\shellex\ContextMenuHandlers”
“HKEY_CLASSES_ROOT\Folder\shell”
“HKEY_CLASSES_ROOT\Folder\shellex\ContextMenuHandlers”
找到后将他们删除即可。
1、理解别人代码时候,先整清楚业务逻辑,然后查看页面dom,再点击页面观察数据变化,最后才看代码
2、vue的$nextick(cb),是在赋值之后立刻调用,视图更新之后回调,适用于数据量很大的渲染
let baseStep = this.baseStep;
if (baseStep == -1) {
return dsbridge.toast('获取步数失败,请重试!本次不扣参与次数');
}
console.log('开始轮询:' + baseStep);
let stopCnt = -2, // 开始游戏后,停止运动了多少个interval。
// 刚开始的话,多2s等待时间,体验更友好。缺点是如果一步也没跑的话,5s才能自动结束
// 3s不动就自动结束游戏
interval = setInterval(() => {
if (stopCnt < 4) {
// 正常不会超过3,否则说明轮询已结束,这个判断主要处理如下情况:
// 在清除定时器的瞬间,其实有最后一次已经开始倒计时,只不过还没执行,这次执行不会被终止,下次执行才会被终止。这导致stopRun可能被连续调用两次
dsbridge.getStep(step => {
// console.log('获取到的步数:' + step);
let newStep = step - baseStep;
console.log('显示的步数:' + newStep);
if (newStep == this.step) {
if (stopCnt == 3) {
stopCnt = 99;
clearInterval(interval);
this.stopRun();
} else {
stopCnt++;
}
} else {
stopCnt = 0; // 动了就重置
this.step = newStep;
// 极限20分钟,如果每分钟250步,就是5000步
if (newStep >= 5000) {
stopCnt = 99;
clearInterval(interval);
this.stopRun();
dsbridge.toast('超出步数上限!自动结束游戏');
}
}
});
}
}, 1000);
pushState和replaceState是一个HTML5的新接口,他们的作用非常大,可以做到改变网址却不需要刷新页面,这个特性后来用到了单页面应用中比如:vue-router,react-router-dom里面,咱们就先看看它的原理和使用案例吧。
最常用的方法:
window.history.pushState(null,null,'download?id=1');
完整使用:var oState= {title: '下载' };window.history.pushState(oState, '下载', 'download?id=1')
;
特点:pushState()可以创建历史,可以配合popstate事件,可以使用history.go(-1)返回到上一个页面。比如:window.addEventListener('popstate', function(evt){var state = evt.state;document.title= state.title; }, false);
最常用的方法:
window.history.replaceState(null,null,'download?id=1');
完整使用:var oState= {title: '下载' };window.history.replaceState(oState, '下载', 'download?id=1');
特点:replaceState不会加入到历史记录里面,用history.go(-1)会跳过当前页面相当于是history.go(-2)。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.