第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

TypeError: undefined is not an object in

TypeError: undefined is not an object in

慕碼人2483693 2022-10-21 10:14:21
我對 Javascript 和 ReactJS 真的很陌生,并且對錯誤感到困惑TypeError: undefined is not an object (evaluating '_this.state = { destination: '' }')這是我的代碼:import React, {Component} from 'react';import { StyleSheet, View, TextInput } from 'react-native';export default class SearchBar extends Component {    constructor() {        /*        this.state = {            destination: ''        };        */        super();    }    render() {        return (            <View style={styles.inputContainer}>                <TextInput                    style={styles.input}                />            </View>        );    }}這段代碼工作正常。但是一旦我取消評論this.state = {            destination: ''        };我得到了錯誤。為什么它在困擾我undefined?我沒有在任何地方訪問它。這可能看起來像這里問題的重復(fù), 但不同之處在于,在該問題中,解決方案涉及.bind(this)在提問者定義的函數(shù)上使用。我沒有這樣的功能,我可以調(diào)用它。任何幫助將不勝感激。
查看完整描述

1 回答

?
慕的地10843

TA貢獻1785條經(jīng)驗 獲得超8個贊

this由 配置super。執(zhí)行之前super,this尚未配置。這就是您遇到問題的原因。使固定:


constructor(props) {

    super(props);

    this.state = {

        destination: ''

    };

}


查看完整回答
反對 回復(fù) 2022-10-21
  • 1 回答
  • 0 關(guān)注
  • 278 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號