zoukankan      html  css  js  c++  java
  • 小程序中使用lodash报错 | lodash小程序报错

    直接在小程序中使用lodash会报错,原因可参考

    https://blog.xinshangshangxin.com/2016/11/30/mina-lodash/

    在 import {_} from 'lodash' 之前先 import 'fix'

    fix.js

    /*fix.js*/
    /*
    修复lodash在小程序中不能使用问题*/ try { global.Array = Array } catch (e) { console.log('Array not support in MINA, skip') } try { global.Buffer = Buffer } catch (e) { console.log('Buffer not support in MINA, skip') } try { global.DataView = DataView } catch (e) { console.log('DataView not support in MINA, skip') } try { global.Date = Date } catch (e) { console.log('Date not support in MINA, skip') } try { global.Error = Error } catch (e) { console.log('Error not support in MINA, skip') } try { global.Float32Array = Float32Array } catch (e) { console.log('Float32Array not support in MINA, skip') } try { global.Float64Array = Float64Array } catch (e) { console.log('Float64Array not support in MINA, skip') } try { global.Function = Function } catch (e) { console.log('Function not support in MINA, skip') } try { global.Int8Array = Int8Array } catch (e) { console.log('Int8Array not support in MINA, skip') } try { global.Int16Array = Int16Array } catch (e) { console.log('Int16Array not support in MINA, skip') } try { global.Int32Array = Int32Array } catch (e) { console.log('Int32Array not support in MINA, skip') } try { global.Map = Map } catch (e) { console.log('Map not support in MINA, skip') } try { global.Math = Math } catch (e) { console.log('Math not support in MINA, skip') } try { global.Object = Object } catch (e) { console.log('Object not support in MINA, skip') } try { global.Promise = Promise } catch (e) { console.log('Promise not support in MINA, skip') } try { global.RegExp = RegExp } catch (e) { console.log('RegExp not support in MINA, skip') } try { global.Set = Set } catch (e) { console.log('Set not support in MINA, skip') } try { global.String = String } catch (e) { console.log('String not support in MINA, skip') } try { global.Symbol = Symbol } catch (e) { console.log('Symbol not support in MINA, skip') } try { global.TypeError = TypeError } catch (e) { console.log('TypeError not support in MINA, skip') } try { global.Uint8Array = Uint8Array } catch (e) { console.log('Uint8Array not support in MINA, skip') } try { global.Uint8ClampedArray = Uint8ClampedArray } catch (e) { console.log('Uint8ClampedArray not support in MINA, skip') } try { global.Uint16Array = Uint16Array } catch (e) { console.log('Uint16Array not support in MINA, skip') } try { global.Uint32Array = Uint32Array } catch (e) { console.log('Uint32Array not support in MINA, skip') } try { global.WeakMap = WeakMap } catch (e) { console.log('WeakMap not support in MINA, skip') } try { global._ = _ } catch (e) { console.log('_ not support in MINA, skip') } try { global.clearTimeout = clearTimeout } catch (e) { console.log('clearTimeout not support in MINA, skip') } try { global.isFinite = isFinite } catch (e) { console.log('isFinite not support in MINA, skip') } try { global.parseInt = parseInt } catch (e) { console.log('parseInt not support in MINA, skip') } try { global.setTimeout = setTimeout } catch (e) { console.log('setTimeout not support in MINA, skip') }

    本文地址:

    https://www.cnblogs.com/stumpx/p/13212266.html

  • 相关阅读:
    实践javascript美术馆的小案例,学习到的东西还是蛮多的,包括javascript编程中的预留退路、分离javascript、以及实现向后兼容等
    HTML5的渐变色 渐变的两种类型 createLinearGradient 和createRadialGradient
    (转)tar 解压缩命令
    VM下的linux系统上不了网?? 使用putty远程登录不上linux的解决方法?
    Js全等和等于
    JavaScript踩坑
    div height 自适应高度 占满剩余高度的方法
    iframe边距问题解决
    Vue.Js初学踩坑
    Linq.js表达式常见写法
  • 原文地址:https://www.cnblogs.com/stumpx/p/13212266.html
Copyright © 2011-2022 走看看