1 Star 2 Fork 1

陈晓怡/rc-comp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.gitee
config
src
assets
router
views
components
demo
hello
mock
browser.js
calendarSelect.js
dateRange.js
drag.js
drawerLayout.js
exTable.js
fileUploader.js
handleDate.js
handleEvents.js
handleNumber.js
handleReg.js
inputSelect.js
lazyLoad.js
matterCalendar.js
mousePosition.js
printA4.js
printA4Table.js
rangePicker.js
simpleTree.js
sortButton.js
textareaNum.js
toggleModal.js
treeSelect.js
useIconfont.js
util
app.js
index.html
index.js
static
.babelrc
.gitignore
README.md
package.json
s.yaml
yarn.lock
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
mousePosition.js 1.33 KB
一键复制 编辑 原始数据 按行查看 历史
import React from 'react';
import { Button, Input } from 'antd';
const { TextArea } = Input;
export default class MousePositionDemo extends React.Component {
constructor(props) {
super(props);
}
state = {
// 文本域内容
content: '',
// 文本域中光标起始位置
textareaStart: 0
}
// 在文本中插入文字aaa
insertAAA() {
const { content, textareaStart } = this.state;
const before = content.substring(0, textareaStart);
const after = content.substring(textareaStart);
this.setState({ content: `${before}aaa${after}` });
}
render() {
const { content } = this.state;
return (
<div className='pd20'>
<TextArea
value={content}
onChange={(e) => this.setState({ content: e.target.value })}
onSelect={e => this.setState({ textareaStart: e.target.selectionStart })}
style={{ width: 500, height: 120, minHeight: 120 }}
ref={r => this.textarea = r}
/>
<Button onClick={() => this.insertAAA()} type="primary" className='ml10'>插入aaa</Button>
<p className='mt20'>输入结果{content}</p>
</div>
);
}
}
export { MousePositionDemo }
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/chenxiaoyi27/rc-comp.git
git@gitee.com:chenxiaoyi27/rc-comp.git
chenxiaoyi27
rc-comp
rc-comp
master

搜索帮助