将Vue与Redactor一起使用

时间:2017-03-23 20:44:29

标签: vue.js vuejs2 redactor redactor.js

我在Redactor上使用v模型。当我这样做时,它返回“事件”而不是我正在寻找的实际数据。关于如何返回正确数据的任何想法?

HTML

<div id="question-create-form">
  <textarea class="form-control question-create-editor" id="question_description" rows="3"></textarea>
</div>

JS

$('#question-create-form .question-create-editor').redactor({
    imageUpload:'/urlGoesHereBro/',
    plugins: ['video', 'imagemanager', 'counter', 'limiter'],
    buttonsHide:['html', 'formatting', 'deleted', 'indent', 'outdent', 'alignment', 'horizontalrule']
  });
  $('#question-create-form .redactor-editor').attr('v-model', 'questionDescription');

1 个答案:

答案 0 :(得分:3)

Redactor似乎是一个jQuery小部件,这意味着它可以通过操作DOM来工作。 Vue希望控制DOM,这意味着两者将相互踩在一起。脚趾除非您将(Redactor的)DOM操作限制在wrapper component的生命周期挂钩中。

要制作Redactor组件work with v-model,需要:

  1. 接受value道具
  2. 使用新值
  3. 发出input事件