Skip to content

Instantly share code, notes, and snippets.

@boonyasukd
Created July 27, 2017 07:03
Show Gist options
  • Save boonyasukd/806c53abe7391f73de249fef781c6f3d to your computer and use it in GitHub Desktop.
Save boonyasukd/806c53abe7391f73de249fef781c6f3d to your computer and use it in GitHub Desktop.
Assignment 11
<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>
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)
})
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