首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么在呈现部分会出现这个解析错误?

为什么在呈现部分会出现这个解析错误?
EN

Stack Overflow用户
提问于 2020-09-18 07:21:59
回答 2查看 39关注 0票数 0

请帮帮我,我不明白怎么回事。我得到了这段代码,我有以下错误:

语法错误:意料之外的标记,预期的";“它指向呈现后的第一个卷曲括号。

这是代码

代码语言:javascript
复制
import Clarifai from 'clarifai'
import Navigation from './components/Navigation/navigation';
import FaceRecognition from './components/FaceRecognition/facerecognition';
import Logo from './components/Logo/logo';
import ImageLinkForm from './components/ImageLinkForm/imagelinkform';
import Rank from './components/Rank/rank';
import './App.css';
import  'tachyons'
import Particles from 'react-particles-js';




const app = new Clarifai.App({
 apiKey: 'fec62103a7704ea8b8ae7f951dc0b823'
});


const particlesOptions = {
    particles: {
        number: {
          value: 70,
          density: {
            enable: true,
            value_area: 800
          }
        }
    }
};

class App extends Component {
  constructor() {
    super();
    this.state = {
      input: '',
      imageUrl: '',
      box:{}
    }
  }
};
  calculateFaceLocation = (data) => {
      const clarifaiFace = data.output[0].data.regions[0].region_info.bounding_box;
      const image = document.getElementById('inputimage');
      const width = Number(image.width);
      const height = Number(image.height);
      console.log(width,height);
    };

  onInputChange = (event) => {
    this.setState({input: event.target.value});
  };

  onButtonSubmit = () => {
    this.setState({imageUrl: this.state.input});
    app.models
    .predict(
      Clarifai.FACE_DETECT_MODEL, 
      this.state.input)
    .then(response => this.calculateFaceLocation(response))
    .catch (err => console.log(err));
  
    
  render() {
    return (
      <div className="App">
        <Particles className='particles'
          params={particlesOptions}
        />,
        <Navigation />,
        <Logo />,
        <Rank />,
        <ImageLinkForm 
        onInputChange={this.onInputChange} 
        onButtonSubmit={this.onButtonSubmit}
        />,
        <FaceRecognition imageUrl={this.state.imageUrl} />
      </div>
    );
  }
export default App;

老实说,我不知道是怎么回事。我已经查过几次了,但我想这个错误只是逃避了。谢谢你们时间的安排。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-09-18 08:38:52

onButtonSubmit丢失了}

代码语言:javascript
复制
onButtonSubmit = () => {
    this.setState({imageUrl: this.state.input});
    app.models
    .predict(
      Clarifai.FACE_DETECT_MODEL, 
      this.state.input)
    .then(response => this.calculateFaceLocation(response))
    .catch (err => console.log(err));
}; // here it is (should be :))
票数 1
EN

Stack Overflow用户

发布于 2020-09-18 08:41:03

在您的代码中,我已经清理、格式化和修复了缺失的"}“。

代码语言:javascript
复制
import Clarifai from "clarifai";
import Navigation from "./components/Navigation/navigation";
import FaceRecognition from "./components/FaceRecognition/facerecognition";
import Logo from "./components/Logo/logo";
import ImageLinkForm from "./components/ImageLinkForm/imagelinkform";
import Rank from "./components/Rank/rank";
import "./App.css";
import "tachyons";
import Particles from "react-particles-js";

const app = new Clarifai.App({
    apiKey: "fec62103a7704ea8b8ae7f951dc0b823",
});

const particlesOptions = {
    particles: {
        number: {
            value: 70,
            density: {
                enable: true,
                value_area: 800,
            },
        },
    },
};

class App extends Component {
    constructor() {
        super();
        this.state = {
            input: "",
            imageUrl: "",
            box: {},
        };
    }
    calculateFaceLocation = (data) => {
        const clarifaiFace =
            data.output[0].data.regions[0].region_info.bounding_box;
        const image = document.getElementById("inputimage");
        const width = Number(image.width);
        const height = Number(image.height);
        console.log(width, height);
    };

    onInputChange = (event) => {
        this.setState({ input: event.target.value });
    };

    onButtonSubmit = () => {
        this.setState({ imageUrl: this.state.input });
        app.models
            .predict(Clarifai.FACE_DETECT_MODEL, this.state.input)
            .then((response) => this.calculateFaceLocation(response))
            .catch((err) => console.log(err));
    };

    render() {
        return (
            <div className="App">
                <Particles className="particles" params={particlesOptions} />,
                <Navigation />,
                <Logo />,
                <Rank />,
                <ImageLinkForm
                    onInputChange={this.onInputChange}
                    onButtonSubmit={this.onButtonSubmit}
                />
                ,
                <FaceRecognition imageUrl={this.state.imageUrl} />
            </div>
        );
    }
}
export default App;

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

https://stackoverflow.com/questions/63951036

复制
相关文章

相似问题

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