【问题标题】:When using fortawesome, script5017 syntax error occurs in internet explorer 11使用fortawesome时,internet explorer 11出现script5017语法错误
【发布时间】:2022-06-22 18:28:21
【问题描述】:

控制台报错信息就像下面这个语句

script5017 syntax error in regular expression

chunk-vendors.js (96290,5)

chunk-vendors.js

!*** ./node_modules/core-js/modules/es.regexp.constructor.js ***!
...
result = inheritIfRequired(NativeRegExp(pattern, flags), thisIsRegExp ? this : RegExpPrototype, RegExpWrapper); // line 96290
...

ma​​in.js

import 'core-js/stable'
import "core-js/es/symbol";
import 'regenerator-runtime/runtime'
import 'intersection-observer' // Optional
import Vue from 'vue'
import App from './App.vue'
import { BootstrapVue, IconsPlugin } from 'bootstrap-vue'
// fontawesome 6.1.1
import { library } from '@fortawesome/fontawesome-svg-core'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { fas } from '@fortawesome/free-solid-svg-icons';
import { far } from '@fortawesome/free-regular-svg-icons';

// Import Bootstrap an BootstrapVue CSS files (order is important)
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'

// Make BootstrapVue available throughout your project
Vue.use(BootstrapVue)
// Optionally install the BootstrapVue icon components plugin
Vue.use(IconsPlugin)

Vue.component('font-awesome-icon', FontAwesomeIcon)
Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App),
}).$mount('#app')

library.add(
  fas,
  far
)

我也使用BootstrapVue。我觉得有时候BootstrapVue 会和fortawesome 发生冲突。有时即使在 chrome 中使用 BootstrapVue 时,它也不能很好地加载。所以我在这个来源中添加了关于它的声明

无论如何,我不知道为什么js没有被脚本加载5017错误发生。这是core-js 错误还是BootstrapVue 错误?

我用过

@fortawesome/fontawesome-common-types6.1.1

@fortawesome/vue-fontawesome2.0.6

core-js3.20.2

bootstrap4.6.1

bootstrap-vue2.21.2

【问题讨论】:

  • 我找到了a similar issue,并且从cmets中,IE中的错误可能是由于在正则表达式中使用/u标志引起的。 /u modifier 仅在 ECMAScript 6/ES2015 中引入,IE11 仅支持 ES5 标准。您可以深入调查以检查是否是问题所在。

标签: javascript vue.js internet-explorer font-awesome core-js


【解决方案1】:

您似乎正在使用 Font Awesome 6,does not support IE11 已经不再使用了。
你可以降级到 Font Awesome 5,does

您的package.json 应该如下所示:

{
  "devDependencies": {
    "@fortawesome/fontawesome-svg-core": "1.2.36",
    "@fortawesome/free-regular-svg-icons": "^5.15.4",
    "@fortawesome/vue-fontawesome": "^0.1.10",
  },
  "resolutions": {
    "@fortawesome/fontawesome-svg-core": "1.2.36"
  }
}

然后用yarnnpm i 更新。

注意版本"core" <1.3 + *-icons =5.15.4 + vue-fontawesome <1,据我所知,它们对应于“Font Awesome

resolutions 部分可能不是必需的,但无论出于何种原因,我都很难说服 yarn 实际降级到 1.3.0 以下。
您可能需要检查node_modules/@fortawesome/fontawesome-svg-core/package.json 以确认已安装的版本。

问题确实是Font Awesome 6所依赖的missing support for Unicode RegExes in IE11

我花了一些时间尝试使它与 @babel/plugin-proposal-unicode-property-regex 一起工作,但没有成功。

【讨论】:

    猜你喜欢
    • 2020-11-15
    • 2018-08-10
    • 1970-01-01
    • 2023-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-29
    • 1970-01-01
    相关资源
    最近更新 更多