首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >设置Slate.js

设置Slate.js
EN

Stack Overflow用户
提问于 2018-05-23 00:10:11
回答 1查看 1K关注 0票数 1

我正在尝试使用以下代码设置一个简单的slate.js编辑器:

代码语言:javascript
复制
import { Editor } from 'slate-react'
import { Value } from 'slate'

const initialValue = Value.fromJSON({
document: {
nodes: [
  {
    object: 'block',
    type: 'paragraph',
    nodes: [
      {
        object: 'text',
        leaves: [
          {
            text: 'A line of text in a paragraph.',
          },
        ],
      },
    ],
  },
],}, });
 // Define our app...
 class App extends React.Component {
 // Set the initial value when the app is first constructed.
 state = {
   value: initialValue,
 };
 // On change, update the app's React state with the new editor value.
 onChange = ({ value }) => {
   this.setState({ value })
  } // Render the editor.
    render() {
          return <Editor value={this.state.value} onChange={this.onChange} />
 }
}
 export default App

我只是简单地从slate.js walkthorugh复制粘贴了代码,但我得到了以下错误:

代码语言:javascript
复制
./src/App.js
Syntax error: Unexpected character '​' (34:0)

  32 |     this.setState({ value })
  33 |   }
> 34 | ​
     | ^
  35 |   // Render the editor.
  36 |   render() {
  37 |     return <Editor value={this.state.value} onChange={this.onChange} />

这是我第一次同时使用react和slate,我只是想体验一下。我希望你能帮我解释一下哪里出了问题:)

EN

回答 1

Stack Overflow用户

发布于 2018-06-22 20:02:28

我不知道你是不是已经解决了。但我刚刚面对了这个问题,我认为当你从他们的文档中复制它的时候,有一个遗留下来的字符。

尝试完全删除代码块末尾和注释之间的空格,然后将它们添加到您喜欢的位置,这样应该可以!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50472174

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档