diff options
Diffstat (limited to 'examples/value-and-defaultValue.html')
-rw-r--r-- | examples/value-and-defaultValue.html | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/examples/value-and-defaultValue.html b/examples/value-and-defaultValue.html index af53d2c..41835b7 100644 --- a/examples/value-and-defaultValue.html +++ b/examples/value-and-defaultValue.html | |||
@@ -2,7 +2,7 @@ | |||
2 | <html> | 2 | <html> |
3 | 3 | ||
4 | <head> | 4 | <head> |
5 | <title>value-and-defaultValue.js - example - rc-time-picker@1.0.0</title> | 5 | <title>value-and-defaultValue.js - example - rc-time-picker@1.1.0</title> |
6 | <meta name="viewport" | 6 | <meta name="viewport" |
7 | content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"> | 7 | content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"> |
8 | <meta charset="utf-8"/> | 8 | <meta charset="utf-8"/> |
@@ -257,7 +257,7 @@ Monokai Sublime style. Derived from Monokai by noformnocontent http://nn.mit-lic | |||
257 | <body> | 257 | <body> |
258 | <div class="container"> | 258 | <div class="container"> |
259 | <div class="header"> | 259 | <div class="header"> |
260 | <h1>rc-time-picker@1.0.0</h1> | 260 | <h1>rc-time-picker@1.1.0</h1> |
261 | 261 | ||
262 | <p>React TimePicker</p> | 262 | <p>React TimePicker</p> |
263 | </div> | 263 | </div> |
@@ -273,14 +273,12 @@ import ReactDom from <span class="hljs-string">'react-dom'</span>; | |||
273 | 273 | ||
274 | import GregorianCalendar from <span class="hljs-string">'gregorian-calendar'</span>; | 274 | import GregorianCalendar from <span class="hljs-string">'gregorian-calendar'</span>; |
275 | import DateTimeFormat from <span class="hljs-string">'gregorian-calendar-format'</span>; | 275 | import DateTimeFormat from <span class="hljs-string">'gregorian-calendar-format'</span>; |
276 | import zhCn from <span class="hljs-string">'gregorian-calendar/lib/locale/zh_CN'</span>; | ||
277 | |||
278 | import TimePicker from <span class="hljs-string">'rc-time-picker'</span>; | 276 | import TimePicker from <span class="hljs-string">'rc-time-picker'</span>; |
279 | import TimePickerLocale from <span class="hljs-string">'rc-time-picker/lib/locale/zh_CN'</span>; | 277 | import TimePickerLocale from <span class="hljs-string">'rc-time-picker/lib/locale/zh_CN'</span>; |
280 | 278 | ||
281 | <span class="hljs-keyword">const</span> formatter = <span class="hljs-keyword">new</span> DateTimeFormat(<span class="hljs-string">'HH:mm:ss'</span>); | 279 | <span class="hljs-keyword">const</span> formatter = <span class="hljs-keyword">new</span> DateTimeFormat(<span class="hljs-string">'HH:mm:ss'</span>); |
282 | 280 | ||
283 | <span class="hljs-keyword">const</span> now = <span class="hljs-keyword">new</span> GregorianCalendar(zhCn); | 281 | <span class="hljs-keyword">const</span> now = <span class="hljs-keyword">new</span> GregorianCalendar(TimePickerLocale.calendar); |
284 | now.setTime(<span class="hljs-built_in">Date</span>.now()); | 282 | now.setTime(<span class="hljs-built_in">Date</span>.now()); |
285 | 283 | ||
286 | <span class="hljs-keyword">const</span> App = React.createClass({ | 284 | <span class="hljs-keyword">const</span> App = React.createClass({ |
@@ -293,6 +291,11 @@ now.setTime(<span class="hljs-built_in">Date</span>.now()); | |||
293 | <span class="hljs-built_in">console</span>.log(value && formatter.format(value)); | 291 | <span class="hljs-built_in">console</span>.log(value && formatter.format(value)); |
294 | <span class="hljs-keyword">this</span>.setState({ value }); | 292 | <span class="hljs-keyword">this</span>.setState({ value }); |
295 | }, | 293 | }, |
294 | clear() { | ||
295 | <span class="hljs-keyword">this</span>.setState({ | ||
296 | value: <span class="hljs-literal">undefined</span>, | ||
297 | }); | ||
298 | }, | ||
296 | render() { | 299 | render() { |
297 | <span class="hljs-keyword">return</span> ( | 300 | <span class="hljs-keyword">return</span> ( |
298 | <span class="xml"><span class="hljs-tag"><<span class="hljs-title">div</span>></span> | 301 | <span class="xml"><span class="hljs-tag"><<span class="hljs-title">div</span>></span> |
@@ -301,6 +304,7 @@ now.setTime(<span class="hljs-built_in">Date</span>.now()); | |||
301 | <span class="hljs-tag"><<span class="hljs-title">TimePicker</span> <span class="hljs-attribute">formatter</span>=<span class="hljs-value">{formatter}</span> <span class="hljs-attribute">locale</span>=<span class="hljs-value">{TimePickerLocale}</span> | 304 | <span class="hljs-tag"><<span class="hljs-title">TimePicker</span> <span class="hljs-attribute">formatter</span>=<span class="hljs-value">{formatter}</span> <span class="hljs-attribute">locale</span>=<span class="hljs-value">{TimePickerLocale}</span> |
302 | <span class="hljs-attribute">value</span>=<span class="hljs-value">{this.state.value}</span> | 305 | <span class="hljs-attribute">value</span>=<span class="hljs-value">{this.state.value}</span> |
303 | <span class="hljs-attribute">onChange</span>=<span class="hljs-value">{this.handleValueChange}</span>/></span> | 306 | <span class="hljs-attribute">onChange</span>=<span class="hljs-value">{this.handleValueChange}</span>/></span> |
307 | <span class="hljs-tag"><<span class="hljs-title">button</span> <span class="hljs-attribute">onClick</span>=<span class="hljs-value">{this.clear}</span>></span>clear<span class="hljs-tag"></<span class="hljs-title">button</span>></span> | ||
304 | <span class="hljs-tag"></<span class="hljs-title">div</span>></span> | 308 | <span class="hljs-tag"></<span class="hljs-title">div</span>></span> |
305 | ); | 309 | ); |
306 | }, | 310 | }, |