1
1
<template >
2
2
<div id =" app" >
3
- <img alt =" Vue logo" src =" ./assets/logo.png" >
4
- <HelloWorld msg =" Welcome to Your Vue.js + TypeScript App" />
3
+ <div class =" container" >
4
+ <h3 >Example1: A type of value is string</h3 >
5
+ <input type =" date" v-model =" date1" />
6
+ <p >Time: {{ date1 }}</p >
7
+ <p >A type of the value is: {{ function () { return typeof date1; }() }}</p >
8
+ </div >
9
+ <div class =" container" >
10
+ <h3 >Example2: Treat a value as a Date Object</h3 >
11
+ <input type =" date"
12
+ v-bind:value =" date2"
13
+ v-on:input =" date2 = strToDate($event.target.value)"
14
+ />
15
+ <p >{{ date2 }}</p >
16
+ <p >A type of the value is: {{ function () { return typeof date2;}() }}</p >
17
+ </div >
18
+ <div class =" container" >
19
+ <h3 >MyDate: A component of treating a value as a Date Object.</h3 >
20
+ <my-date :date =" date3" />
21
+ </div >
5
22
</div >
6
23
</template >
7
24
8
25
<script lang="ts">
9
26
import { Component , Vue } from ' vue-property-decorator' ;
10
- import HelloWorld from ' ./components/HelloWorld .vue' ;
27
+ import MyDate from ' ./components/MyDate .vue' ;
11
28
12
29
@Component ({
13
30
components: {
14
- HelloWorld ,
31
+ MyDate ,
15
32
},
16
33
})
17
- export default class App extends Vue {}
34
+ export default class App extends Vue {
35
+ private date1: Date = new Date ();
36
+ private date2: Date = new Date ();
37
+ private date3: Date = new Date ();
38
+
39
+ strToDate(date : string ): Date {
40
+ return new Date (date );
41
+ }
42
+ }
18
43
</script >
19
44
20
45
<style >
@@ -26,4 +51,13 @@ export default class App extends Vue {}
26
51
color : #2c3e50 ;
27
52
margin-top : 60px ;
28
53
}
54
+
55
+ .container {
56
+ min-width : 200px ;
57
+ min-height : 300px ;
58
+ border : solid ;
59
+ border-color : black ;
60
+ background-color : cadetblue ;
61
+ margin-bottom : 10px ;
62
+ }
29
63
</style >
0 commit comments