2025年React多页面跳转[通俗易懂]

React多页面跳转[通俗易懂]const queryArray array key keyAlias key if array instanceof Array return null let data for let item of array if item keyAlias key data item

const queryArray = (array, key, keyAlias = 'key') => {
if (!(array instanceof Array)) {
return null
}
let data;
for (let item of array) {
if (item[keyAlias] === key) {
data = item;
break
}
}
if (data) {
return data
}
return null
}
render () { const { app: { locationQuery } } = this.props; tolist.js const { 子页面数据 } = this.state; const { id } = locationQuery; ///获取当前页面地址栏的id const info = queryArray(子页面数据, parseInt(id), 'id'); ///根据id拿到当前页面id下面的数据存放到info console.log(info); let pagination = null; if (this.state.pages) { pagination = this.renderPagination(this.state.page, this.state.pages); } const Functionlist = () => { return (  {info ? // 判断如果有此id 渲染一下内容  

{info.title}

: null} // 如果没有就渲染为空 ) } return ( this.node = node} className={styles.notice}> ) }
      two.js

  •  {
    path:'/video/tolist',
    component:()=>import('../routes/video/tolist') //文件夹 video 下面三个js twolist.js&&&two.js /// video.js为单页面跳转页面
    },
    编程小号
    上一篇 2025-07-31 09:40
    下一篇 2025-08-04 09:51

    相关推荐

    版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
    如需转载请保留出处:https://bianchenghao.cn/hz/137342.html