cuốn sách gpt4 ai đã làm

ios - 非 iPhoneX 设备中的错误 - null 不是对象

In lại Tác giả: Walker 123 更新时间:2023-11-29 05:37:25 hai mươi bốn 4
mua khóa gpt4 Nike

当我在 iPhone X 模拟器上运行我的应用程序时,它按照设计运行,没有错误。

当我在 iPhone 5S、7 和所有其他非 iPhone X 设备上运行它时,我收到一条错误消息:null is not an object (evaluating '_this.props.filters.map)

nhập mô tả hình ảnh ở đây

这是我的代码的渲染部分:

kết xuất() { 
return(


color='gray'
style={{
paddingLeft: '3%',
paddingTop: '2%',
paddingBottom: '2%',
borderBottomColor: 'gray',
borderBottomWidth: 1,
fontSize: 14
}}>Saved Filters
<>
style={{
borderBottomColor: 'gray',
borderBottomWidth: 1,
}}
/>

{
this.props.filters !== null ? this.props.filters.map(
(v, i) => {
return(

<>
key={i}
onPress={() => this.updateCurrentFilter(i)}
style={{
paddingLeft: 10,
fontWeight: "100",
fontSize: 14
}}
>{v.filter_name}
<>
style={{
alignSelf: 'flex-end'
}}
>

name={this.props.checkedFilters !== undefined && this.props.checkedFilters[i] === true ? 'toggle-switch' : 'toggle-switch-off-outline'}
size={29}
style={{top: '7%'}}
color='black'
onPress={() => this.updateCurrentFilter(i)}
/>


)
}
) : null
}

<>
style={{
borderBottomColor: 'gray',
borderBottomWidth: 1,
}}
/>

)
}

这些 props 来自默认状态为 null 的 redux reducer 。

对于非 iPhone X 设备,有什么我应该注意的特定事项吗?

câu trả lời hay nhất

您收到错误,因为 this.props.filters 中有 vô giá trị giá trị

Hãy thử điều này:

        
{
this.props.filters ?
this.props.filters.length > 0 ?
this.props.filters.map((v, i) => {
return(
// your component here
)})
: null
: null
}

关于ios - 非 iPhoneX 设备中的错误 - null 不是对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56907590/

hai mươi bốn 4 0
Walker 123
Hồ sơ

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá taxi Didi miễn phí
Phiếu giảm giá taxi Didi
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress