现有一个基于element-ui开发的后台页面,效果如下:

vue字符串切割

 

 

需要将公司名进行切割,每一行,显示一个公司。

 

二、代码实现

test.vue

<template>
  <el-table
    :data="tableData"
    border
    style="width: 362px">
    <el-table-column
      prop="id"
      label="id"
      width="180">
    </el-table-column>
    <el-table-column
      prop="name"
      label="公司名"
      width="180">
      <template slot-scope="scope">
        <div v-for="item in companyCut(scope.row.name)">
          {{item}}<br>
        </div>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
  export default {
    name: "test",
    data() {
      return {
        tableData: [{
          id: '2016-05-02',
          name: '阿里云',
        }, {
          id: '2016-05-04',
          name: '腾讯控股、字节跳动',
        }, {
          id: '2016-05-01',
          name: '美团、金蝶国际、台积电',
        }]
      }
    },
    methods: {
      // 切割公司列表
      companyCut(name){
        let company=name.split("")
        return company
      },
    }
  }
</script>

<style scoped>

</style>

 

效果如下:

vue字符串切割

 

相关文章:

  • 2021-08-28
  • 2021-07-25
  • 2021-09-28
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-17
  • 2021-09-13
  • 2021-08-21
  • 2022-12-23
  • 2022-02-01
  • 2022-12-23
  • 2021-11-30
相关资源
相似解决方案