Created
July 27, 2017 07:03
-
-
Save boonyasukd/806c53abe7391f73de249fef781c6f3d to your computer and use it in GitHub Desktop.
Assignment 11
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
<template> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3"> | |
<h1>Filters & Mixins</h1> | |
<div>{{ text | reverseText }}</div> | |
<hr> | |
<div>{{ text | counter }}</div> | |
<hr> | |
<div>{{ reverseComputed }}</div> | |
<div>{{ textWithCounter }}</div> | |
<hr> | |
</div> | |
</div> | |
</div> | |
</template> | |
<script> | |
import mixIn from './mixin'; | |
export default { | |
mixins: [mixIn], | |
data() { | |
return { | |
text: 'this is the test.', | |
}; | |
}, | |
filters: { | |
reverseText(txt) { | |
return txt.split('').reverse().join(''); | |
}, | |
}, | |
} | |
</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
import Vue from 'vue' | |
import App from './App.vue' | |
Vue.filter('to-lowercase', value => value.toLowerCase()); | |
Vue.filter('counter', (value) => `${value} (${value.length})`); | |
Vue.mixin({ | |
created() { | |
console.log('Global Mixin - Created Hook'); | |
} | |
}); | |
new Vue({ | |
el: '#app', | |
render: h => h(App) | |
}) |
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
export default { | |
computed: { | |
reverseComputed() { | |
return this.text.split('').reverse().join(''); | |
}, | |
textWithCounter() { | |
return `${this.text} (${this.text.length})`; | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment