El-table: data usage question

use el-table to make a table for dynamic data acquisition. Bind the data : data="tableData" in the el-table tag, add the prop attribute to the el-table-column tag, initialize the tableData in script, tableData: null , and the data cannot be generated according to the official website tableData: [] , as shown in the following figure

.

clipboard.png

:


:

clipboard.png

what is the cause of this problem?

related codes

<template>
  <div>
    <el-table border style="width: 100%" :data="tableData">
      <el-table-column type="index" align="center"></el-table-column>
      <el-table-column label="" prop="serveName" align="center"></el-table-column>
      <el-table-column label="" align="center">
        <el-table-column label="" prop="address" align="center" width="180">
          <template slot-scope="scope">
            <!-- {{ scope.row }} -->
            <el-button size="small" class="el-icon-plus" @click="handleAddTop_address"></el-button>
            <el-tree ref="expandMenuList" class="expand-tree"
              v-if="isLoadingTree"
              :data="addressTreeData"
              node-key="id"
              highlight-current
              :props="defaultProps"
              :expand-on-click-node="false"
              :render-content="renderContent"
              :default-expanded-keys="defaultExpandKeys"
              @node-click="handleNodeClick"></el-tree>
          </template>
        </el-table-column>
        <el-table-column label="" prop="port" align="center" width="180">
          <template slot-scope="scope">
            <!-- {{ scope.row }} -->
            <el-button size="small" class="el-icon-plus" @click="handleAddTop_port"></el-button>
            <el-tree ref="expandMenuList" class="expand-tree"
              v-if="isLoadingTree"
              :data="portTreeData"
              node-key="id"
              highlight-current
              :props="defaultProps"
              :expand-on-click-node="false"
              :render-content="renderContent"
              :default-expanded-keys="defaultExpandKeys"
              @node-click="handleNodeClick"></el-tree>
          </template>
        </el-table-column>
        <el-table-column label="" prop="localhost" align="center" width="200"></el-table-column>
        <el-table-column label="" prop="intro" align="center"></el-table-column>
        <el-table-column label="" prop="products" align="center"></el-table-column>
      </el-table-column>
      <el-table-column label="" prop="remarks" align="center"></el-table-column>
    </el-table>
  </div>
</template>

<script>
import TreeRender from "./tree_render"
// import slotTree from "./slot_tree"
import address from "../../api/address.js"
export default {
  data(){
    return{
       tableData: {
         serveName: "",
         address: "",
         port: "",
         localhost: "",
         intro: "",
         products: "",
         remarks: ""
      },
      maxexpandId: address.maxexpandId,//id
      non_maxexpandId: address.maxexpandId,//id()
      isLoadingTree: false,//
      portTreeData: port.treelist,
      defaultProps: {
        children: "children",
        label: "name"
      },
      defaultExpandKeys: [],
    }
  },
  mounted(){
    this.initExpand()
  },
  methods: {
    initExpand(){
      this.addressTreeData.map((a) => {
        this.defaultExpandKeys.push(a.id)
      });
      this.isLoadingTree = true;
    },
    handleNodeClick(d,n,s){//
      },
      renderContent(h,{node,data,store}){//
      },
      handleAddTop_address(){
      },
      handleAddTop_port(){
      },
      handleAdd(s,d,n){//
        console.log(s,d,n)
      },
      handleEdit(s,d,n){//
        console.log(s,d,n)
      },
      handleDelete(s,d,n){//
      },
  },
}
</script>

<style>
.expand{
  width:100%;
  height:80%;
  overflow:hidden;
}
.expand>div{
  height:85%;
  padding-top:20px;
  width:50%;
  margin:20px auto;
  max-width:400px;
  overflow-y:auto;
}
.expand>div::-webkit-scrollbar-track{
  box-shadow: inset 0 0 6px rgba(0,0,0,.3);
  border-radius:5px;
}
.expand>div::-webkit-scrollbar-thumb{
  background-color:rgba(50, 65, 87, 0.5);
  outline:1px solid slategrey;
  border-radius:5px;
}
.expand>div::-webkit-scrollbar{
  width:10px;
}
.expand-tree{
  border:none;
  margin-top:10px;
}
.expand-tree .el-tree-node.is-current,
.expand-tree .el-tree-node:hover{
  overflow:hidden;
}
.expand-tree .is-current>.el-tree-node__content .tree-btn,
.expand-tree .el-tree-node__content:hover .tree-btn{
  display:inline-block;
}
.expand-tree .is-current>.el-tree-node__content .tree-label{
  font-weight:600;
  white-space:normal;
}
</style>

: data='tableData' the tableData here should be an array, and you wrote it as an object

 tableData: [{
        serveName: '',
        address: '',
        port: '',
        localhost: '',
        intro: '',
        products: '',
        remarks: ''
      },
        {
        serveName: '',
        address: '',
        port: '',
        localhost: '',
        intro: '',
        products: '',
        remarks: ''
      }]

your code is released


tableData is an array containing objects
tableData= [{}, {}]


tableData should be an array, the object you give; if you traverse the object, key is the key value of each attribute
as follows:
const arr = [1mem2, 3, 3, 4]
const obj = {aVera 1, b2jue 3, DJV 4}

console.log (Object.keys (arr)) / / ["0", "1", "2", "3"]
console.log (Object.keys (obj)) / / ["a", "b", "c", "d"]

in the first el-table-item of the component, you wrote type=index, and the expected value should be equal to the array subscript + 1-> 1, 2, 5, 3, 4. And you give it to the object, so there is a case of adding a 1 after the key value in the object


clipboard.png
scope.row

clipboard.png

clipboard.png
for reference only


there is something wrong with the data type. It is obvious that the official requirement is an array, but you write an object, just as the takeout boy only delivers takeout to you, but you ask for express delivery when he contacts you

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9e7d1-19de.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9e7d1-19de.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?