简单设置值无法正确解析



我正在使用简单的标记编辑器,例如

<textarea id="editor-board">
<script>
var simplemde = new SimpleMDE({ element: $("#editor-area")[0] });
simplemde.value("# How are
**This is bold** This is normal
_This is italic_ This is normal
```
commands goes here
demo commands
sudo apt update
```");

但这甚至没有在Textarea中加载插件。

,将设置值设置为value('this is simple text');工作正常。

如何在编辑器中设置标记语法?

您可以使用ES6模板文字尝试这样的东西

var simplemde = new SimpleMDE();
simplemde.value(`# How are
  **This is bold** This is normal
  _This is italic_ This is normal
  ```
  commands goes here
  demo commands
  sudo apt update
  ```
`);
<script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
<link href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p><textarea rows="5" name="text"></textarea></p>

或为ES5做这样的事情:

var simplemde = new SimpleMDE();
simplemde.value("# How aren  **This is bold** This is normaln  _This is italic_ This is normaln  ```n  commands goes heren  demo commandsn  sudo apt updaten  ```n");
<script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
<link href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p><textarea rows="5" name="text"></textarea></p>

相关内容

  • 没有找到相关文章

最新更新