简体   繁体   English

使用 react.js 从-到映射

[英]Map from-to using react.js

I have a map loop that returns a list of values eg 0 - 100. The problem is that this will return the whole list.我有一个返回值列表的映射循环,例如 0 - 100。问题是这将返回整个列表。 I want to only return a specific number of values.我只想返回特定数量的值。 eg (11-20).例如(11-20)。 What would be the best way of implementing this?实现这个的最好方法是什么?

The current code is目前的代码是

const all = this.props.memories.map((value, index) => {
    return (
        <div>
            {value}
                </div>
            )
        })

Use .slice() as this.props.memories.slice(11, 20).map...使用.slice()作为this.props.memories.slice(11, 20).map...

Slice..Use it when you do not want to alter the original contents, instead a shallow copy of that for local change and usage. Slice.. 当你不想改变原始内容时使用它,而不是为了本地更改和使用的浅拷贝。

this.props.memories.slice(11,20).map((value, index) => {
    return (
        <div>{value}</div>
    )
})

在中使用.map<div> 标签-react.js</div><div id="text_translate"><p> 我真的很感激任何帮助。 所以该项目是一个反应项目。</p><p> 这是我获取<a href="https://i.stack.imgur.com/WelCP.png" rel="nofollow noreferrer">的内容:获取请求</a></p><p>这是我从服务器响应的内容: <a href="https://i.stack.imgur.com/e2QG3.png" rel="nofollow noreferrer">Response from server</a></p><p> 我试了一下 Postman,看看我收到的是什么类型的 json。 这是它返回的内容: <a href="https://i.stack.imgur.com/yg6IE.png" rel="nofollow noreferrer">Postman 测试</a></p><p>我遇到的问题是我无法 map 收到的数据。 一旦输入链接,我只想在首页上以一种很好的方式显示接收到的数据。</p><p> 是否可以将 map 放在 div 标签内? 或者还有另一种方法吗?</p><p> <em><strong>请注意该项目是作为功能组件编写的</strong></em></p></div> - Using .map in <div> tag - react.js

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 react.js 中使用 Array.map - Using Array.map in react.js 在中使用.map<div> 标签-react.js</div><div id="text_translate"><p> 我真的很感激任何帮助。 所以该项目是一个反应项目。</p><p> 这是我获取<a href="https://i.stack.imgur.com/WelCP.png" rel="nofollow noreferrer">的内容:获取请求</a></p><p>这是我从服务器响应的内容: <a href="https://i.stack.imgur.com/e2QG3.png" rel="nofollow noreferrer">Response from server</a></p><p> 我试了一下 Postman,看看我收到的是什么类型的 json。 这是它返回的内容: <a href="https://i.stack.imgur.com/yg6IE.png" rel="nofollow noreferrer">Postman 测试</a></p><p>我遇到的问题是我无法 map 收到的数据。 一旦输入链接,我只想在首页上以一种很好的方式显示接收到的数据。</p><p> 是否可以将 map 放在 div 标签内? 或者还有另一种方法吗?</p><p> <em><strong>请注意该项目是作为功能组件编写的</strong></em></p></div> - Using .map in <div> tag - react.js 类型错误:map 不是 function(使用 React.js) - TypeError: map is not a function (Using React.js) React.JS &amp; JSX - 来自对象列表的组件的 Map 仅使用列表中第一个 object 的值 - React.JS & JSX - Map of components from list of objects only using value from first object in list React.js map()不是函数吗? - React.js map() is not a function? React.js和Mapbox:使用react.js时,mapbox map无法正确呈现 - React.js and Mapbox: mapbox map not rendering properly when using react.js 地图值react.js - Map value react.js 使用 react.js 中的 map() 将 FetchedData 从 Api 滑到卡片上 - Slip up to display FetchedData from Api to card using map() in react.js 如何使用 React.js 在 map 方法中重构代码冗余 - How to refactor a code redundancy in the map method using React.js 在 react.js 中使用 map 方法时道具不起作用 - props are not working when using map method in react.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM