File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change 66</ head >
77< body >
88 < div id ="app ">
9- < h1 v-switching-color ="colors "> Vue School</ h1 >
9+ < h1 v-switching-color:fast.underline.textcenter ="colors "> Vue School</ h1 >
1010 </ div >
1111
1212 < script type ="text/javascript ">
1313 Vue . directive ( 'switching-color' , function ( el , binding ) {
14+ const modifiers = binding . modifiers
15+ if ( modifiers . underline ) {
16+ el . style . textDecoration = 'underline'
17+ }
18+ if ( modifiers . textcenter ) {
19+ el . style . textAlign = 'center'
20+ }
21+
22+ const speeds = {
23+ slow : 2000 ,
24+ normal : 1000 ,
25+ fast : 500 ,
26+ crazy : 100
27+ }
28+ const speedName = binding . arg || 'normal'
29+ const speed = speeds [ speedName ]
30+
1431 const colors = binding . value
1532 let i = 0
1633 setInterval ( ( ) => {
1734 el . style . color = colors [ i ++ ]
1835 if ( i > colors . length - 1 ) {
1936 i = 0
2037 }
21- } , 500 )
38+ } , speed )
2239 } )
2340
2441 new Vue ( {
You can’t perform that action at this time.
0 commit comments