【问题标题】:"new Trix is not defined" when using Basecamp / Trix Editor使用 Basecamp / Trix 编辑器时“未定义新的 Trix”
【发布时间】:2020-06-01 16:08:35
【问题描述】:
var attachment = new Trix.Attachment({ content: '<span class="mention">@trix</span>' })
element.editor.insertAttachment(attachment)

我使用了这个 sn-p 但它抛出了错误:Trix is not defined?? 我该如何处理? 谢谢!

【问题讨论】:

    标签: javascript reactjs basecamp trix


    【解决方案1】:

    这可能是因为脚本

    var attachment = new Trix.Attachment({ content: '<span class="mention">@trix</span>' })
    element.editor.insertAttachment(attachment)
    

    在 trix.js 或 npm 包之前执行(但是你正在实现它)。目前,当 Trix 准备就绪时,我还没有找到一个监听器,所以一个快速的解决方案是使用 CDN 而不是那些。

    <script src="https://cdnjs.cloudflare.com/ajax/libs/trix/1.3.0/trix.js"></script>
    

    如果您对使用 CDN 没有问题,这些应该可以工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-27
      • 1970-01-01
      • 2022-07-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多