【发布时间】:2018-06-13 08:23:32
【问题描述】:
我正在努力找出为什么不使用 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