在vue2使用ts的坑(一边踩坑一边记录)

130 阅读1分钟

变量未定义

154c2d5d138cced818562a80030ef61.jpg vue-loader 安装15以上版本,在webpack的配置文件加上

//webpack.config.js
//vue-loader需要15以上版本,否则找不到VueLoaderPlugin
const { VueLoaderPlugin } = require('vue-loader')
{
    module: {
        rules: [
            ...
            {
                test: /\.tsx?$/,
                exclude: /node_modules/,
                use: [
                    'babel-loader',
                    {
                        loader: 'ts-loader',
                        options: {
                            appendTsSuffixTo: [/\.vue$/]
                        }
                    }
                ],

            },
         
        ]
    },
    plugins: [
        ...
        new VueLoaderPlugin()
    ]
}