diff --git a/components/tag/demo/control.md b/components/tag/demo/control.md index 6480344d67..1d515ad22f 100644 --- a/components/tag/demo/control.md +++ b/components/tag/demo/control.md @@ -20,6 +20,15 @@ const App = React.createClass({ ], }; }, + onClose(key, e) { + e.preventDefault(); + if (key === 1) { + console.log('can not close it', this.state.tags); + this.setState({ tags: [...this.state.tags] }); + return; + } + this.handleClose(key); + }, handleClose(key) { const tags = [...this.state.tags].filter(tag => (tag.key !== key) && tag); console.log(tags); @@ -35,7 +44,8 @@ const App = React.createClass({ return (
{this.state.tags.map(tag => - this.handleClose(tag.key)}>{tag.name} + this.onClose(tag.key, e)} + afterClose={() => this.handleClose(tag.key)}>{tag.name} )}