临时指定端口

方式一

port=5000 npm run serve

方式二

npm run serve -- --port 8081

注意:--是不能省略的。

永久配置

vue.config.js中添加

const {defineConfig} = require('@vue/cli-service')
module.exports = defineConfig({
    transpileDependencies: true,
    //更改默认端口
    devServer: {
        open: false, // 自动打开浏览器
        port: 8081,
    },
    //设置是否在开发环境下每次保存代码时都启用 eslint验证
    lintOnSave: false
})
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐