当前位置:   article > 正文

pre标签使HTML页面上获取到的文本保留空格和换行符等格式_txt文本复制到html保留换行符

txt文本复制到html保留换行符

使HTML页面上获取到的文本保留空格和换行符等格式
<pre> 元素可定义预格式化的文本。被包围在 pre 元素中的文本通常会保留空格和换行符。而文本也会呈现为等宽字体。
注:在使用过程中,如果是在移动端会发现文字会超出屏幕,形成横向滚动条,加个样式就好了
<pre>的内容自动换行的问题(兼容多个浏览器):

pre {
white-space: pre-wrap;
white-space: -moz-pre-wrap;
white-space: -pre-wrap;
white-space: -o-pre-wrap;
*word-wrap: break-word;
*white-space : normal ;  
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

在这里插入图片描述

<Modal title="GPU状态信息" fullscreen v-model="gpuShow" footer-hide>
	<pre style="background-color: black;color: white;padding: 10px;">{{gpuStatus[0].gpu01[0]}}</pre>
</Modal>
  • 1
  • 2
  • 3

示例数据格式: 内含空格\n换行符

 data () {
    return {
      gpuStatus: [
        {
          'gpu01': [
            'debug*       up   infinite      1    mix gpu02\n-------------------------------------------------------------------------------\ncores=20  RAM=251g  load=3.05, 2.47, 2.31\n-------------------------------------------------------------------------------\nWed Dec  9 10:02:08 2020       \n+-----------------------------------------------------------------------------+\n| NVIDIA-SMI 450.51.05    Driver Version: 450.51.05    CUDA Version: 11.0     |\n|-------------------------------+----------------------+----------------------+\n| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |\n| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |\n|                               |                      |               MIG M. |\n|===============================+======================+======================|\n|   0  GeForce RTX 208...  On   | 00000000:1A:00.0 Off |                  N/A |\n| 29%   27C    P2    46W / 250W |    960MiB / 11019MiB |      7%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n|   1  GeForce RTX 208...  On   | 00000000:1E:00.0 Off |                  N/A |\n| 29%   32C    P2    62W / 250W |    960MiB / 11019MiB |      7%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n|   2  GeForce RTX 208...  On   | 00000000:3D:00.0 Off |                  N/A |\n| 29%   31C    P2    47W / 250W |    960MiB / 11019MiB |      7%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n|   3  GeForce RTX 208...  On   | 00000000:3E:00.0 Off |                  N/A |\n| 29%   23C    P8     1W / 250W |      3MiB / 11019MiB |      0%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n|   4  GeForce RTX 208...  On   | 00000000:41:00.0 Off |                  N/A |\n| 29%   22C    P8     2W / 250W |      3MiB / 11019MiB |      0%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n|   5  GeForce RTX 208...  On   | 00000000:42:00.0 Off |                  N/A |\n| 30%   31C    P2    53W / 250W |   1450MiB / 11019MiB |      0%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n                                                                               \n+-----------------------------------------------------------------------------+\n| Processes:                                                                  |\n|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |\n|        ID   ID                                                   Usage      |\n|=============================================================================|\n|    0   N/A  N/A    170538      C   ...lurm/anaconda3/bin/python      957MiB |\n|    1   N/A  N/A     32286      C   ...lurm/anaconda3/bin/python      957MiB |\n|    2   N/A  N/A     21865      C   ...lurm/anaconda3/bin/python      957MiB |\n+-----------------------------------------------------------------------------+\n-------------------------------------------------------------------------------\nGPU  User                #Samples    Util: GPU  Mem    CPU    RAM       Peak-GPU-Mem\n0    fudaoyuan-slurm            1           7%   0%   100%   2.2g      960MiB (  9%)\n1    fudaoyuan-slurm            1           7%   0%   100%   2.2g      960MiB (  9%)\n2    fudaoyuan-slurm            1           7%   0%   100%   2.2g      960MiB (  9%)\n3    -                          1           0%   0%     0%   0.0g        3MiB (  0%)\n4    -                          1           0%   0%     0%   0.0g        3MiB (  0%)\n5    -                          1           0%   0%     0%   0.0g     1450MiB ( 13%)\n-------------------------------------------------------------------------------\nJobID      User                  C/GPUs#Alloc.   Used   Runtime   Process\n1466       fudaoyuan-slurm          1/2          0 !        0:57  run.sh                \n1447       fudaoyuan-slurm          1/1          1    1-00:17:52  run.sh                \n1449       fudaoyuan-slurm          1/1          2      15:55:43  run.sh                \n-------------------------------------------------------------------------------\nuser: fudaoyuan-slurm       Directory: /data/fudaoyuan-slurm        Shell:  /bin/bash   3/4 !  (used/allocated)\n-------------------------------------------------------------------------------\n',
            'debug*       up   infinite      1    mix gpu02\n-------------------------------------------------------------------------------\ncores=20  RAM=251g  load=3.05, 2.47, 2.31\n-------------------------------------------------------------------------------\nWed Dec  9 10:02:08 2020       \n+-----------------------------------------------------------------------------+\n| NVIDIA-SMI 450.51.05    Driver Version: 450.51.05    CUDA Version: 11.0     |\n|-------------------------------+----------------------+----------------------+\n| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |\n| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |\n|                               |                      |               MIG M. |\n|===============================+======================+======================|\n|   0  GeForce RTX 208...  On   | 00000000:1A:00.0 Off |                  N/A |\n| 29%   27C    P2    46W / 250W |    960MiB / 11019MiB |      7%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n|   1  GeForce RTX 208...  On   | 00000000:1E:00.0 Off |                  N/A |\n| 29%   32C    P2    62W / 250W |    960MiB / 11019MiB |      7%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n|   2  GeForce RTX 208...  On   | 00000000:3D:00.0 Off |                  N/A |\n| 29%   31C    P2    47W / 250W |    960MiB / 11019MiB |      7%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n|   3  GeForce RTX 208...  On   | 00000000:3E:00.0 Off |                  N/A |\n| 29%   23C    P8     1W / 250W |      3MiB / 11019MiB |      0%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n|   4  GeForce RTX 208...  On   | 00000000:41:00.0 Off |                  N/A |\n| 29%   22C    P8     2W / 250W |      3MiB / 11019MiB |      0%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n|   5  GeForce RTX 208...  On   | 00000000:42:00.0 Off |                  N/A |\n| 30%   31C    P2    53W / 250W |   1450MiB / 11019MiB |      0%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n                                                                               \n+-----------------------------------------------------------------------------+\n| Processes:                                                                  |\n|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |\n|        ID   ID                                                   Usage      |\n|=============================================================================|\n|    0   N/A  N/A    170538      C   ...lurm/anaconda3/bin/python      957MiB |\n|    1   N/A  N/A     32286      C   ...lurm/anaconda3/bin/python      957MiB |\n|    2   N/A  N/A     21865      C   ...lurm/anaconda3/bin/python      957MiB |\n+-----------------------------------------------------------------------------+\n-------------------------------------------------------------------------------\nGPU  User                #Samples    Util: GPU  Mem    CPU    RAM       Peak-GPU-Mem\n0    fudaoyuan-slurm            1           7%   0%   100%   2.2g      960MiB (  9%)\n1    fudaoyuan-slurm            1           7%   0%   100%   2.2g      960MiB (  9%)\n2    fudaoyuan-slurm            1           7%   0%   100%   2.2g      960MiB (  9%)\n3    -                          1           0%   0%     0%   0.0g        3MiB (  0%)\n4    -                          1           0%   0%     0%   0.0g        3MiB (  0%)\n5    -                          1           0%   0%     0%   0.0g     1450MiB ( 13%)\n-------------------------------------------------------------------------------\nJobID      User                  C/GPUs#Alloc.   Used   Runtime   Process\n1466       fudaoyuan-slurm          1/2          0 !        0:57  run.sh                \n1447       fudaoyuan-slurm          1/1          1    1-00:17:52  run.sh                \n1449       fudaoyuan-slurm          1/1          2      15:55:43  run.sh                \n-------------------------------------------------------------------------------\nuser: fudaoyuan-slurm       Directory: /data/fudaoyuan-slurm        Shell:  /bin/bash   3/4 !  (used/allocated)\n-------------------------------------------------------------------------------\n'
          ]
        },
        {
          'gpu02': [
            'debug*       up   infinite      1    mix gpu02\n-------------------------------------------------------------------------------\ncores=20  RAM=251g  load=3.05, 2.47, 2.31\n-------------------------------------------------------------------------------\nWed Dec  9 10:02:08 2020       \n+-----------------------------------------------------------------------------+\n| NVIDIA-SMI 450.51.05    Driver Version: 450.51.05    CUDA Version: 11.0     |\n|-------------------------------+----------------------+----------------------+\n| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |\n| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |\n|                               |                      |               MIG M. |\n|===============================+======================+======================|\n|   0  GeForce RTX 208...  On   | 00000000:1A:00.0 Off |                  N/A |\n| 29%   27C    P2    46W / 250W |    960MiB / 11019MiB |      7%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n|   1  GeForce RTX 208...  On   | 00000000:1E:00.0 Off |                  N/A |\n| 29%   32C    P2    62W / 250W |    960MiB / 11019MiB |      7%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n|   2  GeForce RTX 208...  On   | 00000000:3D:00.0 Off |                  N/A |\n| 29%   31C    P2    47W / 250W |    960MiB / 11019MiB |      7%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n|   3  GeForce RTX 208...  On   | 00000000:3E:00.0 Off |                  N/A |\n| 29%   23C    P8     1W / 250W |      3MiB / 11019MiB |      0%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n|   4  GeForce RTX 208...  On   | 00000000:41:00.0 Off |                  N/A |\n| 29%   22C    P8     2W / 250W |      3MiB / 11019MiB |      0%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n|   5  GeForce RTX 208...  On   | 00000000:42:00.0 Off |                  N/A |\n| 30%   31C    P2    53W / 250W |   1450MiB / 11019MiB |      0%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n                                                                               \n+-----------------------------------------------------------------------------+\n| Processes:                                                                  |\n|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |\n|        ID   ID                                                   Usage      |\n|=============================================================================|\n|    0   N/A  N/A    170538      C   ...lurm/anaconda3/bin/python      957MiB |\n|    1   N/A  N/A     32286      C   ...lurm/anaconda3/bin/python      957MiB |\n|    2   N/A  N/A     21865      C   ...lurm/anaconda3/bin/python      957MiB |\n+-----------------------------------------------------------------------------+\n-------------------------------------------------------------------------------\nGPU  User                #Samples    Util: GPU  Mem    CPU    RAM       Peak-GPU-Mem\n0    fudaoyuan-slurm            1           7%   0%   100%   2.2g      960MiB (  9%)\n1    fudaoyuan-slurm            1           7%   0%   100%   2.2g      960MiB (  9%)\n2    fudaoyuan-slurm            1           7%   0%   100%   2.2g      960MiB (  9%)\n3    -                          1           0%   0%     0%   0.0g        3MiB (  0%)\n4    -                          1           0%   0%     0%   0.0g        3MiB (  0%)\n5    -                          1           0%   0%     0%   0.0g     1450MiB ( 13%)\n-------------------------------------------------------------------------------\nJobID      User                  C/GPUs#Alloc.   Used   Runtime   Process\n1466       fudaoyuan-slurm          1/2          0 !        0:57  run.sh                \n1447       fudaoyuan-slurm          1/1          1    1-00:17:52  run.sh                \n1449       fudaoyuan-slurm          1/1          2      15:55:43  run.sh                \n-------------------------------------------------------------------------------\nuser: fudaoyuan-slurm       Directory: /data/fudaoyuan-slurm        Shell:  /bin/bash   3/4 !  (used/allocated)\n-------------------------------------------------------------------------------\n'
          ]
        },
        {
          'gpu03': [
            'debug*       up   infinite      1    mix gpu02\n-------------------------------------------------------------------------------\ncores=20  RAM=251g  load=3.05, 2.47, 2.31\n-------------------------------------------------------------------------------\nWed Dec  9 10:02:08 2020       \n+-----------------------------------------------------------------------------+\n| NVIDIA-SMI 450.51.05    Driver Version: 450.51.05    CUDA Version: 11.0     |\n|-------------------------------+----------------------+----------------------+\n| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |\n| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |\n|                               |                      |               MIG M. |\n|===============================+======================+======================|\n|   0  GeForce RTX 208...  On   | 00000000:1A:00.0 Off |                  N/A |\n| 29%   27C    P2    46W / 250W |    960MiB / 11019MiB |      7%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n|   1  GeForce RTX 208...  On   | 00000000:1E:00.0 Off |                  N/A |\n| 29%   32C    P2    62W / 250W |    960MiB / 11019MiB |      7%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n|   2  GeForce RTX 208...  On   | 00000000:3D:00.0 Off |                  N/A |\n| 29%   31C    P2    47W / 250W |    960MiB / 11019MiB |      7%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n|   3  GeForce RTX 208...  On   | 00000000:3E:00.0 Off |                  N/A |\n| 29%   23C    P8     1W / 250W |      3MiB / 11019MiB |      0%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n|   4  GeForce RTX 208...  On   | 00000000:41:00.0 Off |                  N/A |\n| 29%   22C    P8     2W / 250W |      3MiB / 11019MiB |      0%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n|   5  GeForce RTX 208...  On   | 00000000:42:00.0 Off |                  N/A |\n| 30%   31C    P2    53W / 250W |   1450MiB / 11019MiB |      0%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n                                                                               \n+-----------------------------------------------------------------------------+\n| Processes:                                                                  |\n|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |\n|        ID   ID                                                   Usage      |\n|=============================================================================|\n|    0   N/A  N/A    170538      C   ...lurm/anaconda3/bin/python      957MiB |\n|    1   N/A  N/A     32286      C   ...lurm/anaconda3/bin/python      957MiB |\n|    2   N/A  N/A     21865      C   ...lurm/anaconda3/bin/python      957MiB |\n+-----------------------------------------------------------------------------+\n-------------------------------------------------------------------------------\nGPU  User                #Samples    Util: GPU  Mem    CPU    RAM       Peak-GPU-Mem\n0    fudaoyuan-slurm            1           7%   0%   100%   2.2g      960MiB (  9%)\n1    fudaoyuan-slurm            1           7%   0%   100%   2.2g      960MiB (  9%)\n2    fudaoyuan-slurm            1           7%   0%   100%   2.2g      960MiB (  9%)\n3    -                          1           0%   0%     0%   0.0g        3MiB (  0%)\n4    -                          1           0%   0%     0%   0.0g        3MiB (  0%)\n5    -                          1           0%   0%     0%   0.0g     1450MiB ( 13%)\n-------------------------------------------------------------------------------\nJobID      User                  C/GPUs#Alloc.   Used   Runtime   Process\n1466       fudaoyuan-slurm          1/2          0 !        0:57  run.sh                \n1447       fudaoyuan-slurm          1/1          1    1-00:17:52  run.sh                \n1449       fudaoyuan-slurm          1/1          2      15:55:43  run.sh                \n-------------------------------------------------------------------------------\nuser: fudaoyuan-slurm       Directory: /data/fudaoyuan-slurm        Shell:  /bin/bash   3/4 !  (used/allocated)\n-------------------------------------------------------------------------------\n'
          ]
        }
      ]
    }
  }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/197736
推荐阅读
相关标签
  

闽ICP备14008679号