美文网首页
JavaScript 应用

JavaScript 应用

作者: 前端混合开发 | 来源:发表于2019-08-22 21:59 被阅读0次

    JS对json数据/对象的操作:

    _findWhere我总结过,但是忘记写在哪儿了。Underscore:

    怎么判断一个string在数组中存在?

    http://www.bootcss.com/p/underscore/

    _.findWhere(list, properties)

    遍历list中的每一个值,返回匹配properties所列出的属性的所有的键 - 值对的第一个值。

    如果没有找到匹配的属性,或者list是空的,那么将返回undefined。

    判断一个值有没有在数组中:

    $scope.chosenAttendee.email in sessions[j].sessionattendees --> does not work

    sessions[j].sessionattendees.indexOf($scope.chosenAttendee.email) --> work well

    sessions[j].sessionattendees.indexOf($scope.chosenAttendee.email)!==-1

    _.findWhere(publicServicePulitzers, {newsroom: "The New York Times"});
    => {year: 1918, newsroom: "The New York Times",
    reason: "For its public service in publishing in full so many official reports,
    documents and speeches by European statesmen relating to the progress and
    conduct of the war."}

    isUndefined();sessions[j].useparticalattendees==undefined

    orderBy(collection, expression, reverse, comparator):

    $scope.attendeeList4Filter = orderBy(collection, expression, reverse, comparator);

    collection可以是数组,或者是object数组;expression就是predicate,按照谁来排序;reverse升序/降序(false/true); comparator是当比较的两个数值相同的时候,为了保证不同平台的一致性,所要定义的一个comparator,如果不写的话,就用orderBy自带的;

    超出的部分隐藏:

    overflow:hidden;

    强制不换行:

    white-space:nowrap;

    多余的部分…省略:

    text-overflow:ellipsis;

    多余的部分直接被剪掉:

    text-overflow:clip;

    点击别的地方,弹出对话框消失:

    $('body')

    .click(

    function(evt){

    if($location.url().indexOf(

    "/addEvent")>=0){

    if(evt.target.id=="filterContainer"||evt.target.id=="filterButton1"||evt.target.id=="filterButton2")

    return;

    else{

    $scope.showAttendeeFilterList=false;

    scope.apply();

    }

    }

    });

    Null和undefined区别( see Jianshu):

    Arrow: left, right, top, bottom:

    .arrow-right{

    float:left;

    margin-left:-1%;

    margin-top:12px;

    border-top:10pxsolidtransparent;

    border-bottom:10pxsolidtransparent;

    border-left:10pxsolid#1D3649;

    }

    .arrow-left{

    position:absolute;

    margin-left:-10px;

    float:left;

    margin-top:10px;

    width:0;

    height:0;

    border-top:10pxsolidtransparent;

    border-bottom:10pxsolidtransparent;

    border-right:10pxsolid#335d80;

    }

    Li hover: directly adding title attribute in <li>

    <li title="{{attendee.option}}"class="col-sm-1col-md-1event-filterattendee">{{attendee.username}}

    ({{attendee.email}})</li>

    Span div 自适应长度:

    display:inline-block;

    float:left;

    同步 异步 阻塞 非阻塞:

    Ion-scroll在iphone上作用但是在android phone上有问题,加上下面这个属性:

    overflow-scroll=false

    或者试试:

    overflow:scroll;

    var的背后:

    js var为什么既可以是数字型也可以是字符串

    1. 声明变量的作用域限制在其声明位置的上下文中,而非声明变量总是全局的。

    在javascript的世界里,一切也皆是对象。

    Ng-if和ng-show的区别:

    有的时候ng-show="showFilter";

    $scope.showFilter = true的时候那个按钮也不现实,不知道为什么?

    frances说可能是cache导致的

    相关文章

      网友评论

          本文标题:JavaScript 应用

          本文链接:https://www.haomeiwen.com/subject/ccfasctx.html