File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
- <div id =" show-blogs" >
2
+ <div v-theme:column = " 'narrow' " id =" show-blogs" >
3
3
<h1 >All Blog Articles</h1 >
4
4
<div v-for =" blog in blogs" class =" single-blog" >
5
- <h2 >{{ blog.title }}</h2 >
5
+ <h2 v-rainbow >{{ blog.title }}</h2 >
6
6
<article >{{ blog.body }}</article >
7
7
</div >
8
8
</div >
Original file line number Diff line number Diff line change @@ -5,6 +5,27 @@ import App from './App.vue'
5
5
// Use vue-resource package
6
6
Vue . use ( VueResource ) ;
7
7
8
+ // Custom directives
9
+ Vue . directive ( 'rainbow' , {
10
+ bind ( el , binding , vnode ) {
11
+ el . style . color = "#" + Math . random ( ) . toString ( 16 ) . slice ( 2 , 8 ) ;
12
+ }
13
+ } ) ;
14
+
15
+ Vue . directive ( 'theme' , {
16
+ bind ( el , binding , vnode ) {
17
+ if ( binding . value == 'wide' ) {
18
+ el . style . maxWidth = "1260px" ;
19
+ } else if ( binding . value = 'narrow' ) {
20
+ el . style . maxWidth = "560px" ;
21
+ }
22
+ if ( binding . arg == 'column' ) {
23
+ el . style . background = '#ddd' ;
24
+ el . style . padding = '20px' ;
25
+ }
26
+ }
27
+ } ) ;
28
+
8
29
new Vue ( {
9
30
el : '#app' ,
10
31
render : h => h ( App )
You can’t perform that action at this time.
0 commit comments