能否解释下,vue项目目录中/build/dev-client.js里的hotClient.subscribe(function(){})什么意思?
发布于 7 年前 作者 webcainiao 4812 次浏览 来自 问答

dev-client.js这个被引用的时候,输出的什么啊?是字符串么?

/* eslint-disable */
require('eventsource-polyfill')
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
hotClient.subscribe(function (event) {//这里怎么解释呀,subscribe的作用是什么?
  if (event.action === 'reload') {
    window.location.reload()
  }
})

webpack.dev.conf.js这里用 拼接数组的方式调用[‘./build/dev-client’].concat(…)。那表示dev-client.js输出的字符串。

// 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]) }) 谁解释一下呗?谢谢

回到顶部