Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. <div id="app">
  2. {{ name() }}
  3. {{ me.lastVisit | moment('DD.MM.YYYY') }}
  4. </div>
  5.  
  6. <script>
  7. // Global Vue Filter
  8. // include moment.js
  9. Vue.filter('moment', function (value, format)
  10. {
  11. var format = format || "YYYY-MM-DD";
  12. return moment.unix(value).format(format)
  13. });
  14.  
  15. var app = new Vue({
  16. el: '#app',
  17. data: {
  18. me: {
  19. firstname: "John",
  20. lastname: "Doe",
  21. lastVisit: 1560492819
  22. }
  23. },
  24. methods: {
  25. name: function ()
  26. {
  27. return this.me.firstname + ' ' + this.me.lastname;
  28. }
  29. },
  30.  
  31. mounted: function ()
  32. {
  33. // Set Page Title
  34. document.title = this.name();
  35. },
  36. computed: {
  37.  
  38. },
  39. watch: {
  40. me: function ()
  41. {
  42. document.title = this.name();
  43. }
  44. },
  45. filters: {
  46.  
  47. }
  48. });
  49. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement