HMR API 的 webpack 文档提到了以下方法:
accept(dependencies: string[], callback: (updatedDependencies) => void) => void
我了解如何接受单个依赖项,但不确定多个依赖项的回调应该是什么样子。
这是我的代码:
var $ = require('jquery')
var page = require('page')
var index = require('./index')
var home = require('./home')
$(function() {
page('/', index)
page('/home', home)
page()
if (module.hot) {
module.hot.accept(['./index', './home'], function(updatedDependencies) {
// what should I put in here?
})
}
})