【问题标题】:why simditor-mention doesn't work at all为什么 simditor-mention 根本不起作用
【发布时间】:2017-02-16 05:06:32
【问题描述】:

我在 .vue 文件中导入 simditor。它运作良好。但是当我导入 simditor-mention 时,它根本不起作用。请告诉我如何让它工作。谢谢。

这是我的代码。

import simditor from 'simditor'
import 'simditor-mention'

https://github.com/mycolorway/simditor

https://github.com/mycolorway/simditor-mention

【问题讨论】:

  • 不应该像import someVarName from 'simditor-mention'
  • 我试过了,还是不行

标签: javascript ecmascript-6 vue.js


【解决方案1】:
  1. simditor-mention的源代码在lib文件夹中。
  2. 它没有exports default 也没有module.exports
  3. demo.html 使用脚本标签中的 lib 作为 <script type="text/javascript" src="lib/simditor-mention.js"></script>

因此,您不能像上面尝试的那样使用import 语法。

你应该试试:

require('simditor-mention/lib/simditor-mention.js')

如果您希望在整个 vuejs 应用程序中访问它,请在您的主 js 文件中,或者在所需的 .vue 文件中。

您可以在 html 中导入脚本标签,如下所示:<script type="text/javascript" src="lib/simditor-mention.js"></script>

【讨论】:

  • 非常感谢您的回复,我有一些问题。 1.它在 lib/simditor-mention.js 中有一个 module.exports 2.我尝试 require('simditor-mention/lib/simditor-mention.js') 并导入 'simditor-mention/lib/simditor-mention.js ',它也不起作用
  • 要使用import,库必须有exports defaultexport const someVarmodule.exports 表示您需要在类似节点/节点的环境中使用 require(somePath) 格式。你也加了declare let SimditorMention,html脚本标签的方式呢?
  • 我的应用程序使用 .vuefiles 。所以 html 脚本标签不起作用。并添加declare let SimditorMention 也不起作用。
  • 你在渲染服务器端吗? @smallStone
  • 非常感谢
猜你喜欢
  • 2011-05-10
  • 1970-01-01
  • 2011-02-26
  • 2017-05-30
  • 2022-07-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-20
相关资源
最近更新 更多