How to Control data Wrap in table by element-ui

  1. Project needs to wrap the newly appended data in table
  2. some related codes
<el-table style="width: 100%" :data="tableData">
  <el-table-column prop="dishName" label="" width="200px"></el-table-column>
  <el-table-column prop="amount" label="" width="50px"></el-table-column>
  <el-table-column prop="money" label="" width=50px></el-table-column>
</el-table>
                
<script>
export default {
  data() {
    return {
      tableData: [{
        dishName: "ewqewqe",
        amount: 1,
        money: 30
      }, {
        dishName: "",
        amount: 2,
        money: 60
      }]
    };
  }
};
</script>
  1. expected effect

clipboard.png

  1. tried to add rn to the dishName string, but failed to achieve the effect
Feb.22,2022

< el-table-column prop= "dishName" label= "dish name" width= "200px" >

<template slot-scope="scope">
    {{scope.row.dishName}}
    <div v-if="scope.row.rn">
        {{scope.row.rn}}
    </div>
</template>

< / el-table-column >


use < template slot-scope= "scope" > < / template >


< el-table-column prop= "dishName" label= "dish name" width= "100" >

<template slot-scope="scope">
    

{{scope.row.dishName}}

<p v-if="scope.row.notSpice!=''" style="color:red;">{{scope.row.notSpice}}

</template>

< / el-table-column >
< script >
export default {
data () {

return {
  tableData: [{
    dishName: "ewqewqe",
    amount: 1,
    money: 30,
    notSpice: ''
  }, {
    dishName: '',
    amount: 2,
    money: 60,
    notSpice: ''
  }]
};

}
};
< / script >


https://element.eleme.io/-sharp/zh.

Menu