借助bundle-loader来实现按需加载。(以下三个步骤)
1.新建一个bundle.js文件。
import React, { Component } from 'react';
export default class Bundle extends React.Component {
state = {
// short for "module" but that's a keyword in js, so "mod"
mod: null
}
componentWillMount() {
this.load(this.props)
}
componentWillReceiveProps(nextProps) {
if (nextProps.load !== this.props.load) {
this.load(nextProps)
}
}
load(p