React 表单refs
React 表单 Refs
2023-09-11 14:17:23 时间
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src="js/react.js"></script>
<script src="js/react-dom.js"></script>
<script src="js/browser.min.js"></script>
</head>
<body>
<div id="example"></div>
<script type="text/babel">
var MyComponent = React.createClass({
handleClick:function(){
console.log(
parseInt(this.refs.num1.value)+
parseInt(this.refs.num2.value));
},
render:function(){
return <div>
<input type="text" ref='num1'/>
<br/>
<input type="text" ref='num2'/>
<br/>
<button onClick={this.handleClick}>求和</button>
</div>
}
})
ReactDOM.render(
<MyComponent/>,
document.getElementById('example')
)
</script>
</body>
</html>
相关文章
- react useRef()函数
- [React Testing] Test your Custom Hook Module with react-hooks-testing-library
- [React Testing] Mock react-transition-group in React Component Tests with jest.mock
- [React + Functional Programming ADT] Create Redux Middleware to Dispatch Multiple Actions
- [React] How to use a setState Updater Function with a Reducer Pattern
- [React Intl] Use a react-intl Higher Order Component to format messages
- [React Intl] Format Numbers with Separators and Currency Symbols using react-intl FormattedNumber
- [React Intl] Install and Configure the Entry Point of react-intl
- [React Native] Using the WebView component
- [Node.js] Mock an API for Local Development in React with Mirage JS
- [React Testing] Hide console.error Logs when Testing Error Boundaries with jest.spyOn
- [React] Override webpack config for create-react-app without ejection
- [React] Forward a DOM reference to another Component using forwardRef in React 16.3
- [Recompose] Stream a React Component from an Ajax Request with RxJS
- [React] Make Controlled React Components with Control Props
- [React Intl] Format Numbers with Separators and Currency Symbols using react-intl FormattedNumber
- [React Intl] Format a Date Relative to the Current Date Using react-intl FormattedRelative
- [React Intl] Install and Configure the Entry Point of react-intl
- [React] Create an Auto Resizing Virtualized List with react-virtualized
- [React Testing] Intro to Shallow Rendering
- atitit.React 优缺点 相比angular react是最靠谱的web ui组件化方案了
- atitit.React 优缺点 相比angular react是最靠谱的web ui组件化方案了
- React(一)react概述、组件、事件
- Taro React组件使用(6) —— RuiSendCode 短信验证码【倒计时】
- 【taro react】---- 编译微信小程序后报错:Error: Minified React error #321;
- 【taro react 错误解决】 ---- Uncaught TypeError: Cannot read properties of null (reading ‘getContext‘)
- 【视频】React ReduxToolkit状态管理:创建store对象及redux调试工具的安装方法