[英]NUXTJS Issue in IE11/Edge When Utilizing 3rd Party Library with Spread Operator
我有一个 NUXTJS (v2.9.2) Web 应用程序,在 IE11 和 Edge 中运行时出现渲染问题。 该应用程序适用于 Chrome、Safari 和 FireFox。 我已经在引用的 3rd 方 npm 包(vue-mapbox)中将其追踪到了一个扩展运算符。
我已经阅读了一些引用相同问题的帖子,在大多数情况下,修复方法是将引用的第 3 方库包含在 nuxt.config.js 文件的 build > transpile 选项中。
build: {
transpile: [
({ isLegacy }) => isLegacy && "vue-mapbox"
]
}
这个对 nuxt.config.js 文件的添加允许 Web 应用程序在 IE11 和 Edge 中加载,但现在我在所有浏览器中都遇到了 Javascript 错误并且功能丧失。
下面列出的是我达到这一点所采取的步骤:
在 nuxt.config.js 中没有 transpile 选项的原始状态
IE11 & EDGE
SCRIPT1003: Expected ':'
export default {
methods: {
/**
* Emit Vue event with additional data
*
* @param {string} name EventName
* @param {Object} [data={}] Additional data
*/
$_emitEvent(name, data = {}) {
this.$emit(name, {
map: this.map,
component: this,
...data
});
},
使用 nuxt.config.js 中的 transpile 选项更改状态
NUXTJS
WARN in ./node_modules/vue-mapbox/src/components/map/mixins/withAsyncActions.js
"export 'default' (imported as 'promisify') was not found in 'map-promisified'
所有浏览器
Uncaught (in promise) TypeError: Object(...) is not a function
at VueComponent.$_registerAsyncActions (vendors.app.js:79061)
at vendors.app.js:25088
error TypeError: Cannot read property 'querySourceFeatures' of null
at VueComponent.createMapMarkers (:8080/_nuxt/pages/index.js:1418)
at VueComponent.onIdle (:8080/_nuxt/pages/index.js:1365)
at invokeWithErrorHandling (commons.app.js:14784)
at VueComponent.invoker (commons.app.js:15109)
at invokeWithErrorHandling (commons.app.js:14784)
at VueComponent.Vue.$emit (commons.app.js:16807)
at VueComponent.$_emitEvent (vendors.app.js:79571)
at VueComponent.$_emitMapEvent (vendors.app.js:79584)
at r.St.fire (vendors.app.js:53018)
at r._render (vendors.app.js:53022)
在 nuxt.config.js 中为第一个第三方库添加 transpile 选项后,由于应用程序和库之间不同版本的 javascript 之间的不兼容,它似乎破坏了所有功能。
我们能够通过在我们的解决方案中进行以下添加/更改来解决此问题。
import { MglMap, MglGeolocateControl, MglNavigationControl } from "vue-mapbox/dist/vue-mapbox.umd.js";
const ployfillFeatures = [
"fetch",
"Object.entries",
"Element.prototype.classList",
"IntersectionObserver"
].join("%2C");
module.exports = {
mode: "universal",
script: [
{ src: `https://polyfill.io/v3/polyfill.min.js?features=${ployfillFeatures}`, body: true }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.