Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Vue.component('customer-component', {
- props: { customer: null },
- template: '#customer-template',
- data: function () {
- return {
- open: false
- }
- },
- methods: {
- toggle: function () {
- this.open = !this.open;
- }
- }
- })
- var app = new Vue({
- el: '#app',
- data: {
- items: []
- },
- methods: {
- getDataTest_method: function () {
- var self = this;
- $.ajax({
- url: 'Home/GetDocumentCustomer',
- type: 'GET',
- data: {
- },
- success: function (response) {
- self.items = response;
- },
- error: function () {
- alert('error');
- }
- });
- }
- }
- })
- <ol id="app">
- <customer-component v-for="item in items"
- v-bind:customer="item"
- v-bind:key="item.id">
- </customer-component>
- </ol>
- <script type="text/x-template" id="customer-template">
- <li class="">
- <div class="bold"
- v-on:click="toggle">
- {{customer.name}}
- <span>{{open ? '-' : '+'}}</span>
- </div>
- <ul class="" v-show="open">
- <li v-for="(value, key) in customer">
- {{ key }} : {{ value }}
- </li>
- </ul>
- </li>
- </script>
Add Comment
Please, Sign In to add comment