程序员写代码的细节问题

1.写了定时器离开页面要关闭定时器

var pl=setTimeout(function () {

}, 10000);

clearTimeout(pl);

2.文本输入框的必去特殊字符

var b ='';

if(that.ruleForm.title!=''){

for (let i =0; i < that.ruleForm.title.length; i++) {

b += that.ruleForm.title[i].replace(/\s/g, '')

}

}

that.ruleForm.title = b;

that.ruleForm.title =encodeURIComponent(that.ruleForm.title);

你可能感兴趣的:(程序员写代码的细节问题)