如何将自定义按钮添加到Summernote工具栏

问题描述

还有其他人对此有疑问吗?我关注了文档,但未显示按钮。它只是创建一个空的div。控制台中没有错误

文档:https://summernote.org/deep-dive/#custom-button

JS

import numpy as np

x = [1,2,3,4,5,6,7,8,9,10]
y = [700,-700,710,-710,720,-720,730,-730,740,-740]

x = np.array(x)
y = np.array(y)

mask = y >= 0  # positive mask

pos_y = y[mask]  # get the positive values
neg_y = y[~mask]  # get the negative values; ~ is not

fig,(ax1,ax2) = plt.subplots(2,1,figsize=(7,5))
ax1.bar(x[mask],pos_y)  # also mask x to plot the bar at the correct x-tick
ax1.set_title('Positive Values')
ax1.set_ylim(min(pos_y),max(pos_y))
ax1.set_xticks(range(0,12))  # buffer the number of x-ticks,so the x-ticks of the two plots align.

ax2.bar(x[~mask],neg_y)
ax2.set_title('Negative Values')
ax2.set_ylim(min(neg_y),max(neg_y))
ax2.set_xticks(range(0,12))

plt.tight_layout()  # better spacing between the two plots

呈现的HTML

enter image description here

enter image description here

解决方法

我知道了。所以我不得不将HelloButton函数放在$(document).ready()

之外