import collections
from collections import Counter
import numpy as np
import matplotlib.pyplot as plt
list1 = ["red", "blue", "yellow", "yellow", "blue", "green", "pink", "red"]
list2 = ["black", "black", "yellow", "red", "blue", "pink", "pink", "red", "purple", "white", "red", "orange", "red", "brown", "brown"]
list_total = list1 + list2
c1 = Counter(list1)
c2 = Counter(list2)
c_all = Counter(list_total)
labels_total, values_total = zip(*Counter(list_total).most_common())
indexes = np.arange(len(labels_total))
plt.bar(indexes, values_total)
plt.show()
放置webpack
和require.ensure
以加载异步块。
在webpack2中,我们可以使用import
加载异步块。它返回一个promise,所以如果加载失败,我们可以捕获错误并做一些事情。
import
如果使用import("./module").then(module => {
return module.default;
}).catch(err => {
console.log("Chunk loading failed");
});
。如何在加载异步块失败时处理超时或出错?