即使使用填充程序,也未定义Object.values()

问题描述 投票:0回答:1

我正在努力找出为什么没有使用Object.values的垫片。错误监控不断引发如下问题:

Object.values is not a function. (In 'Object.values(L)', 'Object.values' is undefined)

问题是,我认为我已经为不支持Object.values的浏览器提供了一个垫片:

// index.js

import 'es6-shim';
// ...


if (!Object.values) {
  require('object.values').shim();
}

global.App = {
  ...components,
  ...directives,
  ...mixins,
  ...filters,
  ...utils,
};

global.Vue = Vue;

global.ComponentsBootstrap = function ComponentsBootstrap(Vue) {
  if (process.env.NODE_ENV === 'production') {
    Raven
      .config('http://...')
      .addPlugin(RavenVue, Vue)
      .install()
    ;
  }

  const { provideComponents, provideDirectives, provideFilters } = global.App;

  Vue.use(provideComponents);
  Vue.use(provideDirectives);
  Vue.use(provideFilters);
};

代码使用如下:

 <script src="dist/components/app.js"></script>

 <script>
     ComponentsBootstrap(Vue);
     // include other components that use `Object.values()`
 </script>

是因为在function ComponentsBootstrap中没有调用require('object.values')。shim()?

javascript ecmascript-6 shim
1个回答
0
投票

在IE11中运行的某些ES6代码中,我使用es6-shim作为polyfill遇到了同样的问题。听起来像es6-shim几乎没有通过es7-shim解决的间隙,例如https://github.com/es-shims/es7-shim

© www.soinside.com 2019 - 2024. All rights reserved.