zoukankan      html  css  js  c++  java
  • Vue技巧小结(持续更新)

    1. 动态生成的input自动focus

    背景:

    input元素在需要时才插入DOM,这时元素用autofocus属性第一次是可以获取焦点,但是如果有第二个,就不再生效,所以得另外的办法。

    方法:

    //在input插入DOM后,这样才能focus到。
    setTimeout(function(){   inputElem.focus(); }, 0); //技巧

     2. plupload插件引入时报“mOxie undefined”

    背景:

    vue引入plupload插件(plupload.full.min.js)报上面的错,这个是因为这个文件依赖mOxie对象,而mOxie对象没有正常export出来。

    //export代码
    (function(exports) { "use strict"; var o = {}, inArray = exports.moxie.core.utils.Basic.inArray; // directly add some public classes (function addAlias(ns) { var name, itemType; for (name in ns) { itemType = typeof(ns[name]); if (itemType === 'object' && !~inArray(name, ['Exceptions', 'Env', 'Mime'])) { addAlias(ns[name]); } else if (itemType === 'function') { o[name] = ns[name]; } } })(exports.moxie); // add some manually o.Env = exports.moxie.core.utils.Env; o.Mime = exports.moxie.core.utils.Mime; o.Exceptions = exports.moxie.core.Exceptions; // expose globally exports.mOxie = o; if (!exports.o) { exports.o = o; } return o; })(this);

    这里的this在vue require已经不是window, 所以才没有正常暴露出来了。

    方法:

    (function(){
        //用这个包裹一下,就正常了。
    }).call(window);
  • 相关阅读:
    C语言程序设计第5堂作业
    C语言程序设计第4堂作业
    gets和fgets函数的区别
    编写一个程序实现strcpy函数的功能
    编写一个程序实现strcmp函数的功能
    编写一个程序实现strcat函数的功能
    11-1. 通讯录的录入与显示(10)
    11-0. 平面向量加法(10)
    10-4. 字符串循环左移(20)
    10-3. 字符串逆序(15)
  • 原文地址:https://www.cnblogs.com/lovesong/p/7274019.html
Copyright © 2011-2022 走看看