File tree Expand file tree Collapse file tree 3 files changed +11
-11
lines changed
src/examples/src/flight-booker/App Expand file tree Collapse file tree 3 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -16,15 +16,15 @@ export default {
16
16
17
17
function book ( ) {
18
18
alert (
19
- `You have booked a ${ flightType . value } leaving on ${
20
- departureDate . value
21
- } ${ isReturn . value ? ` and returning on ${ returnDate . value } ` : `` } `
19
+ isReturn . value
20
+ ? `You have booked a return flight leaving on ${ departureDate . value } and returning on ${ returnDate . value } .`
21
+ : `You have booked a one-way flight leaving on ${ departureDate . value } . `
22
22
)
23
23
}
24
24
25
25
function stringToDate ( str ) {
26
26
const [ y , m , d ] = str . split ( '-' )
27
- return new Date ( + y , + m , + d )
27
+ return new Date ( + y , m - 1 , + d )
28
28
}
29
29
30
30
function dateToString ( date ) {
Original file line number Diff line number Diff line change 1
1
function stringToDate ( str ) {
2
2
const [ y , m , d ] = str . split ( '-' )
3
- return new Date ( + y , + m , + d )
3
+ return new Date ( + y , m - 1 , + d )
4
4
}
5
5
6
6
function dateToString ( date ) {
@@ -31,17 +31,17 @@ export default {
31
31
} ,
32
32
canBook ( ) {
33
33
return (
34
- this . isReturn ||
34
+ ! this . isReturn ||
35
35
stringToDate ( this . returnDate ) > stringToDate ( this . departureDate )
36
36
)
37
37
}
38
38
} ,
39
39
methods : {
40
40
book ( ) {
41
41
alert (
42
- `You have booked a ${ this . flightType } leaving on ${ this . departureDate } ${
43
- this . isReturn ? ` and returning on ${ this . returnDate } ` : ` `
44
- } `
42
+ this . isReturn
43
+ ? `You have booked a return flight leaving on ${ this . departureDate } and returning on ${ this . returnDate } . `
44
+ : `You have booked a one-way flight leaving on ${ this . departureDate } . `
45
45
)
46
46
}
47
47
}
Original file line number Diff line number Diff line change 1
1
< select v-model ="flightType ">
2
- < option > one-way flight</ option >
3
- < option > return flight</ option >
2
+ < option value =" one-way flight " > One-way Flight </ option >
3
+ < option value =" return flight " > Return Flight </ option >
4
4
</ select >
5
5
6
6
< input type ="date " v-model ="departureDate " />
You can’t perform that action at this time.
0 commit comments