我试图通过 ap\xc4\xb1 获取数据,我确实做到了。但是,我在拆分方面遇到问题。我尝试了所有方法,但仍然出现此错误。我怎样才能做到这一点?
\n编辑:我安装了这个$npm add react-split \n 并像这样导入它:import Split from 'react-split'。\n这是它在代码中的用法:
\nimport React, {Component} from "react";\nimport { Link } from "react-router-dom";\n\n class PokemonDetail extends Component {\n constructor(props) {\n super(props);\n this.state = {\n name: '',\n imgUrl: '',\n pokemonIndex: '',\n \n };\n}\ncomponentDidMount() {\n const {name, url} = this.props;\n const pokemonIndex = url.split('/')[url.split('/').length - 2];\n const imageUrl = `https://github.com/PokeAPI/sprites/blob/master/sprites/pokemon/${pokemonIndex}.png?raw=true`;\n \n this.setState ({\n name: name,\n imageUrl: imageUrl,\n pokemonIndex: pokemonIndex \n });\n}\nRun Code Online (Sandbox Code Playgroud)\n