小编Yas*_*ins的帖子

React:拆分的类型错误:无法读取未定义的属性(读取“拆分”)

我试图通过 ap\xc4\xb1 获取数据,我确实做到了。但是,我在拆分方面遇到问题。我尝试了所有方法,但仍然出现此错误。我怎样才能做到这一点?

\n

编辑:我安装了这个$npm add react-split \n 并像这样导入它:import Split from 'react-split'。\n这是它在代码中的用法:

\n
import 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}\n
Run Code Online (Sandbox Code Playgroud)\n

split typescript reactjs react-native

1
推荐指数
1
解决办法
6811
查看次数

标签 统计

react-native ×1

reactjs ×1

split ×1

typescript ×1