zoukankan      html  css  js  c++  java
  • javascript编程杂记

    1.数组深复制

    var obj =[1,2,4];

    var obj2 = obj.slice(0);

    2.vue-resource对params参数(get请求)做处理

    如果params中属性为undefined或{}或[],则自动delete该属性后发给后端

    为null则会转化为''

    例 :

    get请求参数为 {a:null,b:undefined,c:{},d:[],e:122}

    最后后台接受到的可能是

    {a:'',e:122}

    3.getComputedStyle是一个可以获取当前元素所有最终使用的CSS属性。

    4.add(1,2,3)(2)

    function add(...arg){
                    let i = 0;
                    let len = arg.length;
                    add.p = add.p||0;
                    for(;i<len;i++){
                        add.p += arg[i];
                    };
                    add.toString = function(){
                        return add.p;
                    }
                    return add;
                }

    5.前端通过_id获取日期

    var timestamp = _id.toString().substring( 0, 8 );
    var date = new Date( parseInt( timestamp, 16 ) * 1000 );

    6.VUE项目中通过引入babel-plugin-transform-vue-jsx实现jsx语法

     
    export default {
        name:'anchored-heading',
        render(createElement){
            return (<div>{this.$slots.default}</div>);
        }
    } 

     7.vue select问题总结

    <select v-model="event_status" class="form-control">
        <option value="" selected>全部</option>//选中,event_status值为空字符串''
      <option :value="" selected>全部</option>//若选中,event_status值为undefined <option v-for="item in activityStatus" :value="item.status"> {{ item.content }} </option> </select>

     8.instanceof 与 isprototypeof用法

    [] instanceof Object // true
    Object.prototype.isprototypeof([]) //true function对象的原型,也是引用类型
    var a = new String('222');
    a instanceof Object //true


    /**
     *  .--,       .--,
     * ( (  .---./  ) )
     *  '.__/o   o\__.'
     *     {=  ^  =}
     *      >  -  <
     *     /       
     *    //       \
     *   //|   .   |\
     *   "'       /'"_.-~^`'-.
     *        _  /--'         `
     *    ___)( )(___
     *   (((__) (__)))    高山仰止,景行行止.虽不能至,心向往之。
     */
    

     

  • 相关阅读:
    Codeforces Round #592 (Div. 2)C. The Football Season(暴力,循环节)
    Educational Codeforces Round 72 (Rated for Div. 2)D. Coloring Edges(想法)
    扩展KMP
    poj 1699 Best Sequence(dfs)
    KMP(思路分析)
    poj 1950 Dessert(dfs)
    poj 3278 Catch That Cow(BFS)
    素数环(回溯)
    sort与qsort
    poj 1952 buy low buy lower(DP)
  • 原文地址:https://www.cnblogs.com/dupd/p/6137360.html
Copyright © 2011-2022 走看看