nuxt i18n 无法在 IE 中运行并抛出 SCRIPT1006:应为 ')'

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

我正在尝试让 nuxt-i18n 适用于 IE 文档模式 11.

SCRIPT1006:应为 ')'

我从这个链接看到 nuxt-i18n 修复了 6.23.0 版本中与脚本错误相关的问题, https://github.com/nuxt-modules/i18n/issues/329

但我的以下代码仍然遇到相同的错误

package.json

{
"name": "t",
"version": "1.0.1",
"description": "t",
"author": "t t",
"private": true,
"scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "test": "jest -u - runInBand - coverage - passWithNoTests",
    "generate": "nuxt generate",
    "lint": "eslint - ext .js,.vue - ignore-path .gitignore .",
    "lint:fix": "eslint - fix - ext .js,.vue - ignore-path .gitignore .",
    "lint:css": "stylelint - fix ./**/*.{vue,scss,css}"
},
"lint-staged": {
    "*.{js,vue}": "npm run lint:fix",
    "*.{css,vue}": "npm run lint:css"
},
"husky": {
    "hooks": {
        "pre-commit": "lint-staged"
    }
},
"dependencies": {
    "@babel/compat-data": "7.19.4",
    "@babel/core": "7.21.3",
    "@babel/generator": "7.19.6",
    "@babel/helper-compilation-targets": "7.19.3",
    "@babel/helper-create-class-features-plugin": "7.19.0",
    "@babel/helper-module-transforms": "7.19.6",
    "@babel/preset-env": "7.12.17",
    "@nuxtjs/axios": "5.12.2",
    "@nuxtjs/dotenv": "1.4.0",
    "@nuxtjs/proxy": "2.0.1",
    "@nuxtjs/pwa": "3.0.0–0",
    "@nuxtjs/vuetify": "1.11.3",
    "axios": "0.21.0",
    "babel-polyfill": "6.26.0",
    "bootstrap-vue": "2.21.2",
    "cookie-universal-nuxt": "2.1.4",
    "json5": "2.2.1",
    "jsonwebtoken": "8.5.1",
    "lodash": "4.17.20",
    "moment": "2.29.1",
    "nuxt": "2.12.2",
    "nuxt-i18n": "6.27.0",
    "vue-jest": "3.0.7",
    "vuex-persist": "3.1.3",
    "@babel/plugin-transform-runtime": "7.21.4",
    "core-js": "2.6.12"
},
"devDependencies": {
    "@nuxtjs/eslint-config": "2.0.0",
    "@nuxtjs/eslint-module": "1.0.0",
    "@nuxtjs/stylelint-module": "3.1.0",
    "babel-eslint": "10.0.1",
    "node-sass": "6.0.1",
    "sass-loader": "10.3.1",
    "stylelint": "10.1.0",
    "stylelint-config-standard": "20.0.0"
},
"config": {
    "nuxt": {
        "host": "0.0.0.0"
    }
},
"engines": {
    "node": "16.x"
}

}

和我的nuxt配置

    require('babel-polyfill')
import i18n from './config/i18n'
const features = [
    'fetch',
    'Object.entries',
    'es2015',
    'es5',
    'es6',
    'IntersectionObserver',
    'Object.defineProperty'
].join('%2C');
export default {
    mode: 'universal',
    // env:{
    // VUE_APP_APIURL1: process.env.VUE_APP_APIURL1 || 'null'
    // },
    publicRuntimeConfig: {
        myPublicVariable: process.env.VUE_APP_APIURL1 || 'test',
    },
    head: {
        title: process.env.npm_package_name || '',
        meta: [{
                charset: 'utf-8'
            },
            {
                'http-equiv': 'X-UA-Compatible',
                content: 'IE=Edge'
            },
            {
                name: 'viewport',
                content: 'width=device-width, initial-scale=1'
            },
            {
                hid: 'description',
                name: 'description',
                content: process.env.npm_package_description || ''
            }
        ],
        link: [{
            rel: 'icon',
            type: 'image/x-icon',
            href: '/favicon.ico'
        }],
        script: [{
                src: `https://polyfill.io/v3/polyfill.min.js?features=${features}`,
                body: true
            },
            {
                src: 'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.23.0/polyfill.min.js'
            }
        ]
    },
    /*
     ** Customize the progress-bar color
     */
    loading: {
        color: '#fff'
    },
    /*
     ** Global CSS
     */
    css: [],
    /*
     ** Plugins to load before mounting the App
     */
    plugins: [
        '~/plugins/env.js'
    ],
    /*
     ** Nuxt.js dev-modules
     */
    buildModules: [
        '@nuxtjs/vuetify',
        '@nuxtjs/dotenv',
        ['nuxt-i18n',
            {
                vueI18nLoader: true,
                defaultLocale: 'en',
                locales: [{
                        code: 'en',
                        name: 'English'
                    },
                    {
                        code: 'fr',
                        name: 'Français'
                    }
                ],
                vueI18n: i18n
            }
        ]
        // Doc: https://github.com/nuxt-community/eslint-module
        // '@nuxtjs/eslint-module',
        // Doc: https://github.com/nuxt-community/stylelint-module
        // '@nuxtjs/stylelint-module'
    ],
    /*
     ** Nuxt.js modules
     */
    modules: [
        '@nuxtjs/pwa',
        '@nuxtjs/axios',
        '@nuxtjs/proxy',
        // Doc: https://github.com/nuxt-community/dotenv-module
        'cookie-universal-nuxt',
        'bootstrap-vue/nuxt'
    ],
    bootstrapVue: {
        components: ['BTabs', 'BTab']
    },
    axios: {
        proxyHeaders: true,
        init(axios, ctx) {
            axios.defaults.headers.post['Content-Type'] = 'application/json;'
        }
    },
    /*
     ** Build configuration
     */
    build: {
        babel: {
            "presets": [
                [
                    "@babel/preset-env",
                    {
                        "useBuiltIns": "usage",
                        "corejs": "2.6.12"
                    },
                ],
            ],
            "plugins": [
                "@babel/plugin-transform-runtime"
            ],
        },
        postcss: null,
        transpile: [],
        vendor: ['axios'],
        /*
         ** You can extend webpack config here
         */
    }
};

有没有人以前遇到过同样的问题并且知道如何解决它?

也创建了问题 https://github.com/nuxt-modules/i18n/issues/2041

javascript nuxt.js internet-explorer-11 nuxt-i18n
© www.soinside.com 2019 - 2024. All rights reserved.