-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
datetime-view: new component (extend from datetime) (ref #1635)
- Loading branch information
Showing
8 changed files
with
159 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<template> | ||
<div></div> | ||
</template> | ||
|
||
<script> | ||
import Datetime from '../datetime' | ||
import Picker from '../datetime/datetimepicker' | ||
import objectAssign from 'object-assign' | ||
export default { | ||
extends: Datetime, | ||
methods: { | ||
render () { | ||
this.$nextTick(() => { | ||
this.picker && this.picker.destroy() | ||
this.picker = new Picker(objectAssign(this.pickerOptions, { | ||
renderInline: true | ||
})) | ||
this.picker.show() | ||
}) | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
icon: '' | ||
methods: | ||
render: | ||
version: next | ||
en: re-render component | ||
zh-CN: 强制重新渲染组件,当主动修改值或者其他非响应属性时需要调用该方法 | ||
changes: | ||
next: | ||
en: | ||
- '[feature] new component' | ||
zh-CN: | ||
- '[feature] 新组件 DatetimeView' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<template> | ||
<div> | ||
<datetime-view v-model="value1" ref="datetime" :format="format"></datetime-view> | ||
<p class="info">current value: {{ value1 }}</p> | ||
<div style="padding:15px;"> | ||
<x-button @click.native="changeValue('2017-11-11')" :disabled="format !== 'YYYY-MM-DD'" type="primary">set 2017-11-11</x-button> | ||
<x-button @click.native="changeValue('2016-08-08')" :disabled="format !== 'YYYY-MM-DD'" type="primary">set 2016-08-08</x-button> | ||
<x-button @click.native="toggleFormat" type="primary">toggle format</x-button> | ||
<x-button @click.native="showPopup = true" type="primary">show popup with datetime-view</x-button> | ||
</div> | ||
<div v-transfer-dom> | ||
<popup v-model="showPopup"> | ||
<datetime-view v-model="value2"></datetime-view> | ||
</popup> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { DatetimeView, XButton, Popup, TransferDom } from 'vux' | ||
export default { | ||
components: { | ||
DatetimeView, | ||
XButton, | ||
Popup | ||
}, | ||
directives: { | ||
TransferDom | ||
}, | ||
data () { | ||
return { | ||
value1: '2017-10-11', | ||
value2: '2017-10-24', | ||
showPopup: false, | ||
format: 'YYYY-MM-DD' | ||
} | ||
}, | ||
methods: { | ||
toggleFormat () { | ||
if (this.format === 'YYYY-MM-DD') { | ||
this.format = 'YYYY-MM-DD HH:mm:ss' | ||
} else { | ||
this.format = 'YYYY-MM-DD' | ||
} | ||
}, | ||
changeValue (val) { | ||
this.value1 = val | ||
this.$refs.datetime.render() | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.info { | ||
padding-top: 15px; | ||
text-align: center; | ||
color: #666; | ||
} | ||
</style> |