總結(jié)Echo中遇到的問題

1.設(shè)置模態(tài)框

需求:點(diǎn)擊離職單選框時下面角色欄的按鈕被禁用。
點(diǎn)擊角色欄管理員單選框時出現(xiàn)權(quán)限選擇框。

2.需求:模態(tài)框彈出再次點(diǎn)擊,填寫過的內(nèi)容清空
class AddPosition extends Component {
    constructor(props){
        super(props);
        this.state = {
            position: '',
        }
    }
    onClean = () => {
        this.setState({ 
            position: '',
        });
    }
    handleCancel = () => {
        this.onClean();
        this.props.handleCancel();
    }
    handleOk = () => {
        this.onClean(); 
        this.props.handleOk();
    }

    render(){
        const { position } = this.state;
        return(
                <Modal
                title="添加職位"
                visible={this.props.visible}
                onOk={this.handleOk}
                onCancel={this.handleCancel}
                className="addModal"
                >
                    <div className="input">
                        <span className="editspan">職位名稱:</span>
                        <Input placeholder="請輸入職位名稱" value={position}
                            onChange = {(e) => this.setState({position: e.target.value})}
                        />
                    </div>
                </Modal>
        )
    }
}
export default connect(({  }) => ({

}))(AddPosition);
3.點(diǎn)擊復(fù)制鏈接時,復(fù)制框內(nèi)內(nèi)容

實(shí)現(xiàn)代碼如下:

/**
     * 點(diǎn)擊復(fù)制鏈接按鈕時復(fù)制框內(nèi)內(nèi)容
     */
    copyLink = () => {
        //console.log(this.refs.fetchSignUpLink)
        if (document.body.createTextRange) {
            var range = document.body.createTextRange();
            range.moveToElementText(this.refs.fetchSignUpLink);
            range.select();
        } else if (window.getSelection) {
            var selection = window.getSelection();
            var range = document.createRange();
            range.selectNodeContents(this.refs.fetchSignUpLink);
            selection.removeAllRanges();
            selection.addRange(range);
            message.success('復(fù)制成功');//點(diǎn)擊復(fù)制之后提示復(fù)制成功
        } 
        document.execCommand("Copy");  
        if (document.selection) { 
          document.selection.empty(); 
        } else if (window.getSelection) { 
          window.getSelection().removeAllRanges(); 
        } 
    }
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容