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

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

應(yīng)用className / onClick / onChange不能處理Custom React

應(yīng)用className / onClick / onChange不能處理Custom React

波斯汪 2019-08-14 15:25:11
應(yīng)用className / onClick / onChange不能處理Custom React Component我?guī)缀跏切率謗eact。我正在嘗試創(chuàng)建一個簡單的編輯和創(chuàng)建掩碼。這是代碼:import React, { Component } from 'react';import Company from './Company';class CompanyList extends Component {     constructor(props) {         super(props);         this.state = {             search: '',             companies: props.companies        };     }     updateSearch(event) {         this.setState({ search: event.target.value.substr(0,20) })     }     addCompany(event) {         event.preventDefault();       let nummer = this.refs.nummer.value;       let bezeichnung = this.refs.bezeichnung.value;       let id = Math.floor((Math.random()*100) + 1);       $.ajax({           type: "POST",           context:this,           dataType: "json",           async: true,           url: "../data/post/json/companies",           data: ({                _token : window.Laravel.csrfToken,               nummer: nummer,               bezeichnung : bezeichnung,           }),           success: function (data) {             id = data.Nummer;             this.setState({               companies: this.state.companies.concat({id, nummer, bezeichnung})             })             this.refs.bezeichnung.value = '';             this.refs.nummer.value = '';           }       });     }     editCompany(event) {       alert('clicked');       event.preventDefault();       this.refs.bezeichnung.value = company.Bezeichnung;       this.refs.nummer.value = company.Nummer;     }     render() {       let filteredCompanies = this.state.companies.filter(         (company) => {           return company.bezeichnung.toLowerCase().indexOf(this.state.search.toLowerCase()) !== -1;         }       );
查看完整描述

2 回答

?
眼眸繁星

TA貢獻(xiàn)1873條經(jīng)驗 獲得超9個贊

你必須在你的子組件上綁定事件:

import React, { Component } from 'react';const Company = ({ company, onClick }) => 
   <li onClick={onClick}>
      {company.Nummer} {company.Bezeichnung}
   </li>export default Company

要么

const Company = ({ company, ...props }) => 
   <li {...props}>
      {company.Nummer} {company.Bezeichnung}
   </li>

如果你想要傳遞給你的Compagny組件(exept compagny)的所有道具都轉(zhuǎn)到你的li標(biāo)簽??碋S6傳播操作員和休息。


查看完整回答
反對 回復(fù) 2019-08-14
  • 2 回答
  • 0 關(guān)注
  • 715 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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