I just ran a previous demo of Vue+webpack. After running, there was no expected effect and an error was reported.
Uncaught TypeError: Cannot assign to read only property’exports’ of object’#<Object>’
Click on the wrong file and mark the wrong place as this piece of code:
import {normalTime} from'./timeFormat'; module.exports = { normalTime };
Is module.exports;
The reason is: The code above is ok. You can mix and . You can’t mix and . require
export
import
module.exports
there is nothing wrong with the code. When webpack is packaged, you can mix require and export in the js file. But import and module.exports cannot be mixed.
Because import and module.exports are not allowed to be mixed in webpack 2,
The solution is to change it to ES6.
import {normalTime} from'./timeFormat' ; export default normalTime;
Finally it runs successfully.