Guest User

Untitled

a guest
Sep 25th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. <body>
  2. <button>open popup #1</button>
  3.  
  4. <popup
  5. inline-template
  6. >
  7. <div class="popup popup_1">
  8. Content #1
  9. </div>
  10. </popup>
  11.  
  12. <popup
  13. inline-template
  14. >
  15. <div class="popup popup_2">
  16. Content #2
  17. </div>
  18. </popup>
  19. </body>
  20. ...
  21.  
  22. <script>
  23. Vue.component('popup', {
  24. methods: {
  25. open: function() {
  26. // ...
  27. },
  28. }
  29. });
  30.  
  31. var app = new Vue({
  32. el: 'body',
  33. });
  34. </script>
  35.  
  36. <template id="template-popup-component">
  37. <button v-on:click="togglePopup">Toggle this popup</button>
  38. <div v-if="isShow" class="popup-content">
  39. <slot></slot>
  40. </div>
  41. </template>
  42. <popup>
  43. Hello, World!
  44. </popup>
  45.  
  46. Vue.component('popup', {
  47. template: '#template-popup-component',
  48. data: function() {
  49. return {
  50. isShow: false
  51. }
  52. },
  53. methods: {
  54. togglePopup: function() {
  55. this.isShow = !this.isShow;
  56. },
  57. }
  58. });
  59.  
  60. var app = new Vue({
  61. el: 'body',
  62. });
Add Comment
Please, Sign In to add comment