配置完,没有报错,但是ie11无法打印,感觉时编译成低版本的js代码错了,帮忙看看
webpack.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | { "name" : "webpack" , "version" : "1.0.0" , "description" : "" , "main" : "index.js" , "scripts" : { "webpack" : "webpack --config webpack.config.js" }, "author" : "" , "license" : "ISC" , "devDependencies" : { "webpack" : "^5.72.0" , "webpack-cli" : "^4.9.2" }, "dependencies" : { "@babel/core" : "^7.17.10" , "@babel/preset-env" : "^7.17.10" , "babel-loader" : "^8.2.5" , "core-js" : "^3.22.4" } } |
webpack.config.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | const path = require( 'path' ); module.exports = { mode: 'development' , entry: { main: "./hhh/index.js" , module: "./hhh/module.js" }, output: { path: path.resolve(__dirname, 'dist' ), filename: "[name].js" , }, module:{ rules:[ { test :/\.js$/, exclude: /node_module/ , loader: "babel-loader" , } ] } } |
.babelrc
1 2 3 | { "presets" :[ "@babel/preset-env" ] } |
编译前的两个js代码
下面这个叫index.js
1 2 3 4 5 6 7 8 9 | import 'core-js/stable' import {value,age} from './module.js' if (value < age){ console.log(1) } else { console.log( 'err' ) } const a = Object.assign({x:0},{y:1}); console.log(a); |
1 2 3 4 | //下面这个叫module.js const value = 10; let age = 20; export {value,age}; |
ie打印结果
麻烦老师帮忙看看。
18
收起
正在回答 回答被采纳积分+1
1回答
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧