Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/436.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript CKEditor 4可以工作,但CKEditor 5不能';T_Javascript_Ckeditor - Fatal编程技术网

Javascript CKEditor 4可以工作,但CKEditor 5不能';T

Javascript CKEditor 4可以工作,但CKEditor 5不能';T,javascript,ckeditor,Javascript,Ckeditor,这项工作: <!DOCTYPE html> <html lang="en"> <head> <title>CKEditor Classic Editing Sample</title> <!-- Make sure the path to CKEditor is correct. --> <script src="scripts/ckeditor/ckeditor.js"></scr

这项工作:

<!DOCTYPE html>
<html lang="en">
<head>
    <title>CKEditor Classic Editing Sample</title>
    <!-- Make sure the path to CKEditor is correct. -->
    <script src="scripts/ckeditor/ckeditor.js"></script>
    <!-- this is with CKEDITOR 4 -->
    <script>
      window.addEventListener("load", function() {
        CKEDITOR.replace ('editor1');
      });
    </script>
</head>
<body>
    <form method="post">
        <p>
            My Editor:<br>
            <textarea name="editor1" id="editor1">&lt;p&gt;Initial editor content.&lt;/p&gt;</textarea>
        </p>
        <p>
            <input type="submit">
        </p>
    </form>
</body>
</html>

我遗漏了什么?

因此,最终我在CKEditor网站上找到了相关文章:

v5的API需要不同的语法:

<!DOCTYPE html>
<html lang="en">
<head>
    <title>CKEditor Classic Editing Sample</title>
    <!-- Make sure the path to CKEditor is correct. -->
    <script src="https://cdn.ckeditor.com/ckeditor5/16.0.0/classic/ckeditor.js"></script>
    <script>
    window.addEventListener("load", function() {
      ClassicEditor
           .create( document.querySelector( '#editor' ) )
           .then( editor => {
                   console.log( editor );
           } )
           .catch( error => {
                   console.error( error );
           } );
    });
    </script>
</head>
<body>
  <div id="editor">This is some sample content.</div>
</body>
</html>

CKEditor经典编辑示例
addEventListener(“加载”,函数(){
分类编辑器
.create(document.querySelector('#editor'))
.然后(编辑=>{
console.log(编辑器);
} )
.catch(错误=>{
控制台错误(error);
} );
});
这是一些示例内容。
也许只有我一个人,但我认为基本的“入门”指南会更好。在将初始化代码放入事件侦听器之前,v5也出现了错误

Uncaught ReferenceError: CKEDITOR is not defined
<!DOCTYPE html>
<html lang="en">
<head>
    <title>CKEditor Classic Editing Sample</title>
    <!-- Make sure the path to CKEditor is correct. -->
    <script src="https://cdn.ckeditor.com/ckeditor5/16.0.0/classic/ckeditor.js"></script>
    <script>
    window.addEventListener("load", function() {
      ClassicEditor
           .create( document.querySelector( '#editor' ) )
           .then( editor => {
                   console.log( editor );
           } )
           .catch( error => {
                   console.error( error );
           } );
    });
    </script>
</head>
<body>
  <div id="editor">This is some sample content.</div>
</body>
</html>