React-- ref
React -- ref
2023-09-27 14:26:50 时间
ref
import React from 'react';
class App extends React.Component {
constructor(props) {
super(props);
this.myref=React.createRef();
}
componentDidMount(){
this.myref.current.style.backgroundColor="#000"
}
render() {
return (
<input ref={this.myref} defaultValue="我是输入框" style={{color:'white'}}/>
);
}
}
export default App;
相关文章
- MacOS安装react。问题 -- npm全局包的权限问题
- React Native-组件的引用
- 入门教程: 认识 React
- react基础语法(五) state和props区别和使用
- react--todoList
- React--diff算法和三种优化策略
- React--组合(类似vue的插槽)
- React--state的正确设计
- react--props对象和数组的类型校验
- react--useRef
- react--antd的基本使用
- react--redux+antd实现todoList
- Typescript+React项目模板
- React Native 新架构
- React-Native极光推送android和ios证书申请
- 在iOS中创建React-Native页面,并跳转到原生页面
- redux在react-native上使用(五)--redux-actions使用
- React Native 使用原生 UI 组件
- React-Native学习之第三方开源组件--侧滑栏----react-native-side-menu
- 从路由原理出发,深入阅读理解react-router 4.0的源码