【发布时间】:2018-02-09 13:32:14
【问题描述】:
我正在尝试将 Redactor 与一些添加的插件一起使用。问题是计数器插件在页面加载后显示0个单词和0个字符。
{
words: 0,
characters: 0,
spaces: 0
}
我尝试使用“init”回调来执行计数器插件的 count() 方法,如文档所示:
$('#content').redactor({
plugins: ['counter'],
callbacks: {
init: function()
{
this.counter.count();
},
counter: function(data)
{
console.log(data);
}
}
});
...此时一切似乎都正常,VSCode 中没有编译错误,但我在控制台中收到以下错误:
declare const $R: any;
...
...
$R('#editor', {
plugins: [
'counter',
...
],
callbacks: {
init: function() {
this.counter.count();
}
counter: function(data: any) {
console.log(data);
}
}
});
ERROR TypeError: Cannot read property 'count' of undefined
at App.changed (editor.component.ts:55)
at F._loop (scripts.bundle.js:2741)
at F.trigger (scripts.bundle.js:2711)
at App.broadcast (scripts.bundle.js:2185)
at F._syncing (scripts.bundle.js:10344)
at scripts.bundle.js:10316
at ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:4724)
at ZoneDelegate.invokeTask (zone.js:420)
at Zone.runTask (zone.js:188)
我做错了什么?
谢谢,
【问题讨论】:
-
抱歉,我使用的不是“init”回调,而是“已更改”。
标签: angular typescript redactor redactor.js