问题:ubuntu下vim如何设置tab为4个空格
解决:修改vimrc文件(个人home目录是.vim/.vimrc文件)
方法:
vim /etc/vim/vimrc
添加
set ts=4
set expandtab
现有文件
TAB替换为空格:
:set ts=4
:set expandtab
:%retab!
空格替换为TAB:
:set ts=4
:set noexpandtab
:%retab!
问题:ubuntu下vim如何设置tab为4个空格
解决:修改vimrc文件(个人home目录是.vim/.vimrc文件)
方法:
vim /etc/vim/vimrc
添加
set ts=4
set expandtab
现有文件
TAB替换为空格:
:set ts=4
:set expandtab
:%retab!
空格替换为TAB:
:set ts=4
:set noexpandtab
:%retab!
问题:在js中想知道userInfo json数据中是否存在age这个key
解决:使用in方法
方法:
if(“age” in userInfo){}
或:userInfo.hasOwnProperty("age")
构造函数
Date.prototype.toHyphenDateString = function() {
var year = this.getFullYear();
var month = this.getMonth() + 1;
var date = this.getDate();
var hours=this.getHours();
var minutes=this.getMinutes();
var seconds=this.getSeconds();
if (month < 10) { month = "0" + month; }
if (date < 10) { date = "0" + date; }
if(hours < 10) { hours= "0" + hours}
if(minutes < 10) { minutes= "0" + minutes}
if(seconds < 10) { seconds= "0" + seconds}
return year + "-" + month + "-" + date + " "+hours+":"+minutes+":"+seconds;
};
timeShow();
setInterval(timeShow,1000);
function timeShow(){
var date=new Date();
var str=date.toHyphenDateString();
$('.time').text("当前时间:"+str);//jQuery方法,将时间显示在类为time的标签内
}
问题:希望找一个jquery的时间日期插件
解决:My97日期插件,有时间
方法:
一、在页面中导入脚本
<script type="text/javascript" src="/static/lib/My97DatePicker/WdatePicker.js"></script>
二、给html标签增加Wdate类
<input class="Wdate" type="text" placeholder="时间" />
三、给html标签增加click事件
$('.Wdate').click(function(){
WdatePicker({skin:"twoer", dateFmt:"yyyy-MM-dd HH:mm:ss"});
});
注:html标签class必须有Wdate
问题:jquery的$.post()方法传递数组参数,在python中无法获取
解决:将数组参数变字符串
方法:
var afile = [];
afile.push('{"fname":"'+$(this).attr('id')+'", "oname":"'+$(this).text()+'"}');
sargs['afile'] = afile.toString();
$.post('/bk/api/add/schedule',sargs,function(data){ console.log('ok'); },'json');
服务端:
afile = self.get_argument('afile','')
afile_list = json.loads('['+afile+']')