新建js文件

getIpAddress.js

//获取本机的IP地址
function getNetworkIp() {
    let ip = 'localhost';
    try {
        const network = Os.networkInterfaces();//获取本机的网路
        for (const iter in network) {
            const faces = network[iter];
            for (const interface of faces) {
                if (interface.family === 'IPv4' && interface.address !== '127.0.0.1' && !interface.internal) {
                    ip = interface.address;
                    return ip;
                }
            }
        }
    } catch (e) {

    }
    return ip;
}
module.exports = getNetworkIp;

在index.js文件中添加以下配置

dev: {

    // Paths
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    proxyTable: {},

    // Various Dev Server settings
    host: getNetworkIp(), // can be overwritten by process.env.HOST
    useLocalIp: true,//允许使用本地IP地址进行访问
    port: 18880, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
    autoOpenBrowser: false,
    errorOverlay: true,
    notifyOnErrors: true,
    poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-


    /**
     * Source Maps
     */

    // https://webpack.js.org/configuration/devtool/#development
    devtool: 'cheap-module-eval-source-map',

    // If you have problems debugging vue-files in devtools,
    // set this to false - it *may* help
    // https://vue-loader.vuejs.org/en/options.html#cachebusting
    cacheBusting: true,

    cssSourceMap: false
  },

GitHub 加速计划 / vu / vue
80
16
下载
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
最近提交(Master分支:4 个月前 )
73486cb5 * chore: fix link broken Signed-off-by: snoppy <michaleli@foxmail.com> * Update packages/template-compiler/README.md [skip ci] --------- Signed-off-by: snoppy <michaleli@foxmail.com> Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com> 6 个月前
e428d891 Updated Browser Compatibility reference. The previous currently returns HTTP 404. 6 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐