小编Mic*_*y Q的帖子

如何将 this.props.children 传递给 Textarea

我使用 defaultValue 在 textarea 中传递 this.props.childred 但它给了我错误未捕获错误:如果您defaultValue在 a 上提供,请勿传递子项。

还有什么其他选择或者有更好的方法来确定价值观

import React, {Component} from 'react';

class Update extends Component {

    constructor(props){
        super(props);
        this.state = {
            editing:false
        }

        this.renderEdit = this.renderEdit.bind(this)
    }

    edit(){
        this.setState({
            editing:true
        })

    }
    remove(){
        alert("remove")
    }
    save(){
        this.setState({
            editing:false
        })
    }

    renderNormal(){
        return (
            <div className="container">

        <div className="content"> {this.props.children}</div>
        <button onClick={this.edit.bind(this)} className="edit" >Edit </button>
        <button onClick={this.remove} className="remove" >Remove </button>
        </div>
        );

    }
    renderEdit(){

        console.log( 'this.props ', this.props)

console.log( 'this.props.children ', this.props.children)

        return (
        <div className="container"> …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs

3
推荐指数
1
解决办法
2133
查看次数

1
推荐指数
2
解决办法
9202
查看次数