使用fortawesome时,脚本5017语法错误发生在Internet Explorer中11

发布于 2025-01-20 10:08:56 字数 1976 浏览 2 评论 0原文

控制台错误消息就像在此语句下

script5017 syntax error in regular expression

chunk-vendors.js (96290,5)

块-Dendors.js

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

main.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。我有时觉得Bootstrapvuefortawesome发生了一些冲突。有时,当我在chrome中使用Bootstrapvue时,它也无法很好地加载。因此,无论如何,我在此源中添加了有关它的声明

,我不知道为什么脚本5017错误会加载JS。这可以是core-js错误还是bootstrapvue错误?

我使用

@fortawesome/fontawesome-common-types 6.1.1

@fortawesome/vue-fontawesome 2.0.6

core-js 3.20.2

< 3.20.2 <代码> bootstrap 4.6.1

bootstrap-vue 2.21.2

The console error message is like under this statement

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
...

main.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
)

I use BootstrapVue too. I feel sometimes BootstrapVue makes some conflicts with fortawesome. Sometimes it is not loaded well when I used BootstrapVue with even in chrome. So I added the statement about it in this source

Anyway, I don't know why js isn't loaded by script 5017 error happens. Can this be core-js error or BootstrapVue error?

I used

@fortawesome/fontawesome-common-types 6.1.1

@fortawesome/vue-fontawesome 2.0.6

core-js 3.20.2

bootstrap 4.6.1

bootstrap-vue 2.21.2

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如果没有 2025-01-27 10:08:56

您似乎使用的是 Font Awesome 6,它不支持 IE11 不再有。
您可以降级到 Font Awesome 5,
可以

您的 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据我所知,很棒 < 6 英寸。

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

问题确实是 缺少对Font Awesome 6 所依赖的 IE11 中的 Unicode RegExes。

我花了一些时间尝试使其与 @babel/plugin-proposal-unicode-property-regex 没有成功。

It looks like you're using Font Awesome 6, which does not support IE11 any more.
You could downgrade to Font Awesome 5, which does.

Your package.json should look something like this:

{
  "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"
  }
}

Then update with yarn or npm i.

Note versions "core" <1.3 + *-icons =5.15.4 + vue-fontawesome <1, which correspond to "Font Awesome < 6", as far as I could tell.

The resolutions part might not be necessary, but I had a hard time convincing yarn to actually downgrade below 1.3.0, for whatever reason.
You might want to check node_modules/@fortawesome/fontawesome-svg-core/package.json to confirm the installed version.

The issue is indeed the missing support for Unicode RegExes in IE11, which Font Awesome 6 relies on.

I've spent some time trying to make it work with @babel/plugin-proposal-unicode-property-regex to no success.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文