nestProp.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <script setup lang="ts">
  2. const tableData = [
  3. {
  4. userInfo: { name: "Test1", age: 22 },
  5. other: [
  6. { sex: "女" },
  7. {
  8. more: {
  9. content: '<div><span style="color: red">我是 html 片段</span></div>'
  10. }
  11. }
  12. ],
  13. role: "设计师"
  14. },
  15. {
  16. userInfo: { name: "Test2", age: 28 },
  17. other: [
  18. { sex: "男" },
  19. {
  20. more: {
  21. content:
  22. '<img width="100" height="100" src="https://pure-admin.github.io/pure-admin-table/imgs/11.jpg">'
  23. }
  24. }
  25. ],
  26. role: "后端"
  27. },
  28. {
  29. userInfo: { name: "Test3", age: 20 },
  30. other: [
  31. { sex: "女" },
  32. {
  33. more: {
  34. content:
  35. '<img width="100" height="100" src="https://pure-admin.github.io/pure-admin-table/imgs/1.jpg">'
  36. }
  37. }
  38. ],
  39. role: "程序员鼓励师"
  40. },
  41. {
  42. userInfo: { name: "Test4", age: 26 },
  43. other: [
  44. { sex: "男" },
  45. {
  46. more: {
  47. content:
  48. '<a href="https://github.com/xiaoxian521" target="_black">我是链接,点我去 Follow</a>'
  49. }
  50. }
  51. ],
  52. role: "前端"
  53. }
  54. ];
  55. const columns: TableColumnList = [
  56. {
  57. label: "姓名",
  58. prop: "userInfo.name"
  59. },
  60. {
  61. label: "性别",
  62. prop: "other[0].sex"
  63. },
  64. {
  65. label: "年龄",
  66. prop: "userInfo.age"
  67. },
  68. {
  69. label: "Html片段",
  70. slot: "content"
  71. },
  72. {
  73. label: "角色",
  74. prop: "role"
  75. }
  76. ];
  77. </script>
  78. <template>
  79. <pure-table :data="tableData" :columns="columns">
  80. <template #content="{ row }">
  81. <span v-html="row.other[1].more.content" />
  82. </template>
  83. </pure-table>
  84. </template>