2017-06-01 34 views
0

我在VueJs 2.使用的數據表(https://github.com/pstephan1187/vue-datatable)成分 我的成分如下:錯誤與vuejs丙定義

<template> 
    <div> 

     <div id="desktop"> 
      <div v-if="visibility.personsTable"> 
       <datatable-persons 
         :columns="persons_table_columns" 
         :data="rows" 
         filterable paginate 
       ></datatable-persons> 
      </div> 

     </div>   
    </div> 
</template> 

<script> 
    import VueJsDatatable from 'vuejs-datatable'; 

    import Profile from './user/Profile'; 
    import ConnectionService from '../components/services/ConnectionService'; 
    const connectionService = new ConnectionService(); 

    Vue.component('showuser', { 
     template: ` 
     <button class="btn btn-xs btn-primary" @click="goToUpdatePage">Профиль</button> 
    `, 
     props: [row], 
     methods: { 
      goToUpdatePage: function(){ 

      } 
     } 
    }); 

    export default { 
     components: {    
      datatablePersons: VueJsDatatable, 
      usersTable: VueJsDatatable, 
     }, 

     data() { 
      return { 


        rows: [], 
        persons_table_columns: [ 
         {label: 'id', field: 'id'}, 
         {label: 'Имя', field: 'firstname'}, 
         {label: 'Фамилия', field: 'lastname'}, 
         {label: 'Отчетство', field: 'middlename'}, 
         {label: 'Профиль', component: 'showuser'} 
        ], 


       visibility: { 
        personsTable: false, 
       } 
      } 
     }, 

     methods: { 
      showPersons() { 

      this.$http.get(hostname + 'name=person_list&session_id=' + 

sessionApiId).then(response => { 
        this.rows = connectionService.renderMultipleInstances(response.body); 
        this.visibility.usersTable = false; 
        this.visibility.personsTable = true; 
       }, response => { 
        // error callback 
       }); 
      },   
     } 

    } 
</script> 

我有以下錯誤: 未捕獲的ReferenceError:行不以限定的 Object.defineProperty.value(app.js:5309) 在webpack_require(app.js:20)

由於 「表」 部分的文件,應注意有無 「行託」,用官方爲例它正常工作。

回答

1

在你showuser組件props的定義應該是一個字符串數組:

props: ['row'] 

這些字符串應該與您使用將數據傳遞到該組件的屬性的名稱。

也從sinppet我猜你想它是'rows'不是'row'