成功el-table强制换行

<template>
  <div class="app-container">
    <el-form ref="form" :model="form" label-width="120px">
      <el-form-item label="用户名" prop="username">
        <el-input v-model="form.username" />
      </el-form-item>
      <el-form-item label="添加\n时间">
        <el-date-picker
          v-model="form.addtime"
          type="datetime"
          value-format="yyyy-MM-dd HH:mm:ss"
          placeholder="选择日期时间"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="数量">
        <el-input
          type="text"
          oninput="value=value.replace(/[^\d]/g,'')"
          maxlength="9"
          v-model="form.num1"
          placeholder="请输入数量"
          clearable
        ></el-input>
      </el-form-item>
      <el-form-item style="text-align:center">
        <el-button type="primary" @click="return_list_page();">返回列表</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { getInfo } from "@/api/test";
export default {
  data() {
    return {
      form: {
      
      },
    };
  },
  mounted() {
    var id = this.$route.query.id;
    this.loadData(id);
  },
  methods: {
    return_list_page() {
     this.$router.push("/test_list");
    },
    loadData(id) {
      getInfo(id).then((result) => {
        var _data = result.Data;
        this.form = Object.assign({}, _data);
      });
    },
  },
};
</script>
<style scoped>
.el-table >>>.cell{
  white-space:pre-line;
}
</style>

关键代码:

<style scoped>
.el-table >>>.cell{
  white-space:pre-line;
}

加上这个样式,这样换行符\n就会换行

(0)

相关推荐