发表于: 2019-04-10 20:30:02

1 820



今天完成的事情:

今天继续做任务四,由于接了个任务 ,所以任务四做的不多,主要是把后面要用到的数据添加到对象的属性上

for (i = 0i < data.lengthi++) {
temp.push({
role: data[i].role,
isdied: "false",
number: i + 1,
kmode: "notyet",
ktime: "notyet"
});
}

后面的话,对比了一下之前师兄的代码,bug有点多,需要增加和修改的地方很多,明天继续做吧,


明天计划的事情:

明天计划继续做任务四,这周完成。

遇到的问题:

$(".user").click(function () {
$(".user").removeClass("red");
var index = $(this).index();

代码如上写的时候,点击无论其中任何一个事件对象的时候,index一直等于0;

解决方案:应该这样写

$(".user").click(function () {
$(".user").removeClass("red");
var index = $(".user").index($(this));

原因:

使用index()的元素,是相对于jQuery选择器$(".user")中元素index位置。因为我要获取当前点击的元素在$(".user")中的索引,所以应该改成第二张图的写法。

获取下标

收获:

//获取sessionStorage存储数据
export const getCache = name => {
    if (!name) return
    return window.sessionStorage.getItem(name)
}
//设置sessionStorage存储数据
export const setCache = (name, content) => {
    if (!name) return
    if (typeof content !== 'string') {
        content = JSON.stringify(content)
    }
    window.sessionStorage.setItem(name, content)
}
//删除sessionStorage存储数据
export const removeCache = (name) => {
    if (!name) return
    window.sessionStorage.removeItem(name)
}



返回列表 返回列表
评论

    分享到