Pass single value within onClick (without using a form submit)

前端 未结 2 1287
谎友^
谎友^ 2021-01-29 08:51

Rather than creating several putPriority fetches, I\'d ideally just like to pass a singular value.

But this value won\'t be entered via the user (ie not an input field)<

2条回答
  •  悲哀的现实
    2021-01-29 09:02

    You can use bind() to pass value to the handleClick function and the instead of this.state.level just use value liek

    body: JSON.stringify({
         status:value,
         tag:[
           {}
          ]
      })
    

    var App = React.createClass ({
    putPriority: function(value, e) {
        e.preventDefault();
        console.log(value);
      },
    
      render: function(){
            return (
              
    ) } }) ReactDOM.render(, document.getElementById('app'));
    
    
    

提交回复
热议问题