Guest User

Untitled

a guest
Oct 20th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. Vue.component('customer-component', {
  2. props: { customer: null },
  3. template: '#customer-template',
  4. data: function () {
  5. return {
  6. open: false
  7. }
  8. },
  9. methods: {
  10. toggle: function () {
  11. this.open = !this.open;
  12. }
  13. }
  14. })
  15.  
  16. var app = new Vue({
  17. el: '#app',
  18. data: {
  19. items: []
  20. },
  21. methods: {
  22. getDataTest_method: function () {
  23. var self = this;
  24. $.ajax({
  25. url: 'Home/GetDocumentCustomer',
  26. type: 'GET',
  27. data: {
  28. },
  29. success: function (response) {
  30. self.items = response;
  31. },
  32. error: function () {
  33. alert('error');
  34. }
  35. });
  36. }
  37. }
  38. })
  39.  
  40. <ol id="app">
  41. <customer-component v-for="item in items"
  42. v-bind:customer="item"
  43. v-bind:key="item.id">
  44. </customer-component>
  45. </ol>
  46.  
  47. <script type="text/x-template" id="customer-template">
  48. <li class="">
  49. <div class="bold"
  50. v-on:click="toggle">
  51. {{customer.name}}
  52. <span>{{open ? '-' : '+'}}</span>
  53. </div>
  54. <ul class="" v-show="open">
  55. <li v-for="(value, key) in customer">
  56. {{ key }} : {{ value }}
  57. </li>
  58. </ul>
  59. </li>
  60. </script>
Add Comment
Please, Sign In to add comment