IE11的Vuetify / Lib Polyfilling无法正常工作-SCRIPT1002:语法错误

Sco*_*ker 5 .net-core asp.net-core babel-polyfill vuetify.js asp.net-core-mvc-2.0

我正在尝试vuetify/lib使用通常的方法进行引用import Vuetify from "vuetify/lib",但是当我这样做时,该应用程序在IE11中由于阻塞了SCRIPT1003: Expected ':'

如果我将引用更改为import Vuetify from "vuetify"-没有/lib部分-它不会引发错误。

请注意,我实际上尚未在任何地方使用 vuetify。我没有一个Vuetify组件或电话;我只是添加库。

现在,表面上看,IE11包含了vuetify并愉快地对其进行了解析,我想使用一些组件。如果我在模板中放置了任何 vuetify组件,则IE11会抛出一条Script1002: Syntax Error消息。

任何人都有建议使它真正起作用吗?

Index.cshtml

<v-app>
  <div id="reportApp"></div>
</v-app>
Run Code Online (Sandbox Code Playgroud)

入口点

// polyfills
import "core-js/stable";
import "regenerator-runtime/runtime";

import Vue from "vue"
import "@mdi/font/css/materialdesignicons.css"
import reportFilter from "./reportFilter.vue"

const options = {
    el: "#reportApp",
    render: h => h(reportFilter)
};

export default new Vue(options);
Run Code Online (Sandbox Code Playgroud)

reportFilter.vue

<template>
    <div>
      <!-- this will throw a syntax error -->
      <v-progress-circular indeterminate color="primary"
      ></v-progress-circular>
    </div>
</template>

<script>
    import axios from 'axios'

    export default {
        name: 'report-filter',
        data: function(){
            return {
                dataTypeList: [
                    { value: "1", text: "one" },
                    { value: "2", text: "two" },
                    { value: "3", text: "three" }
                ]
            }
        },
    }

</script>
Run Code Online (Sandbox Code Playgroud)

webpack.config.js

const path = require("path");
const fs = require("fs");
const { VueLoaderPlugin } = require("vue-loader");
const VuetifyLoaderPlugin = require("vuetify-loader/lib/plugin");

module.exports = {
    entry: jsEntries,  // setting jsEntries removed for clarity
    mode: "development",
    module: {
        rules: [
            // other rules for css/sass/etc removed for clarity
            /*javascript*/{
                test: /\.m?js$/,
                exclude: [
                    /node_modules/,
                    /bower_components/
                ],
                use: {
                    loader: "babel-loader",
                    options: {
                        presets: [
                            [
                                "@babel/preset-env",
                                {
                                    "targets": {
                                        "browsers": [
                                            "last 2 versions",
                                            "ie >= 11"
                                        ]
                                    },
                                    "corejs": "3",
                                    "useBuiltIns": "entry"
                                }
                            ]
                        ]
                    }
                }
            },
            /*vue*/{
                test: /\.vue$/i,
                use: "vue-loader"
            }
        ]
    },
    output: {
        filename: "[name].js",
        path: path.resolve(__dirname, "./wwwroot/dist/js/"),
        publicPath: "/wwwroot/dist/js/"
    },
    plugins: [
        new VueLoaderPlugin(),
        new VuetifyLoaderPlugin()
    ],
    resolve: {
        alias: {
            vue: "vue/dist/vue.js"
        }
    }
};
Run Code Online (Sandbox Code Playgroud)

Aur*_*a W 0

Vuejs 论坛中遇到类似问题的用户报告称,使用 babel 来填充此特定问题取得了成功。

我的建议是安装 babel polyfill,将其导入到你的 app.js 中并配置 babel.config.js,如下所示

如果您要积极使用 Vuetify,您还应该在声明选项应用程序之前使用 Vue.use(Vuetify),否则 Vue 将不知道它需要使用该包。