vue无法自动打开浏览器

vue

原文链接: 点我

如果不能自动浏览器" title="打开浏览器">打开浏览器,是因为没有安装插件。

插件安装的方法
1.安装插件,在cmd中输入:

$ npm i open-browser-webpack-plugin --save
这里的 i 表示 install ,是缩写。

2.修改build\webpack.dev.conf.js文件。
在顶部声明最下面加入:

var OpenBrowserPlugin = require(\'open-browser-webpack-plugin\')
在plugins中加入:

new OpenBrowserPlugin({ url: \'http://localhost:8080\' }),

var config = require(\'../config\')

var webpack = require(\'webpack\')

var merge = require(\'webpack-merge\')

var utils = require(\'./utils\')

var baseWebpackConfig = require(\'./webpack.base.conf\')

var HtmlWebpackPlugin = require(\'html-webpack-plugin\')

var FriendlyErrors = require(\'friendly-errors-webpack-plugin\')

var OpenBrowserPlugin = require(\'open-browser-webpack-plugin\')

// add hot-reload related code to entry chunks

Object.keys(baseWebpackConfig.entry).forEach(function (name) {

baseWebpackConfig.entry[name] = [\'./build/dev-client\'].concat(baseWebpackConfig.entry[name])

})

module.exports = merge(baseWebpackConfig, {

module: {

loaders: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })

},

// eval-source-map is faster for development

devtool: \'#eval-source-map\',

plugins: [

new OpenBrowserPlugin({ url: \'http://192.168.10.105:8080\' }),

new webpack.DefinePlugin({

\'process.env\': config.dev.env

}),

// https://github.com/glenjamin/webpack-hot-middleware#installation--usage

new webpack.optimize.OccurrenceOrderPlugin(),

new webpack.HotModuleReplacementPlugin(),

new webpack.NoErrorsPlugin(),

// https://github.com/ampedandwired/html-webpack-plugin

new HtmlWebpackPlugin({

filename: \'index.html\',

template: \'index.html\',

inject: true

}),

new FriendlyErrors()

]

})


3.最后,在运行npm run dev 即可。

以上是 vue无法自动打开浏览器 的全部内容, 来源链接: utcz.com/z/377594.html

回到顶部