【问题标题】:Creating Element UI tooltip content that changes depending on the table-row创建根据表格行更改的元素 UI 工具提示内容
【发布时间】:2021-02-09 19:31:28
【问题描述】:

我有一个方法可以根据元素 UI 表中的列值返回一个字符串到工具提示内容,但是它只返回第一列的值,而不是在悬停后更改。

<el-table-column label="Service Lines / MSDRG" prop="code" sortable min-width="120">
  <template slot-scope="slotData">
    <el-tooltip 
      effect="dark" 
      placement="top-start" 
      :content="returnSvclinesValue(slotData.row.code , name)"
    >
    <span>{{ slotData.row.code }}</span>
    </el-tooltip>
   </template>
</el-table-column>

这里是returnSvclineValue(code, name)的方法

returnSvclinesValue: function(code, name) {
  const svclinesTrimmedByName = svclines.find(i => i.label == name && i.value == name)
  const svclineValue = svclinesTrimmedByName.children.find(l => l.value = code )
  return svclineValue.label
}

对于returnSvclinesValue(code, name) 方法,它可以工作,我只需要它根据行的代码呈现不同的内容。有什么解决方法吗?

【问题讨论】:

    标签: javascript vue.js element-ui


    【解决方案1】:

    使用如下所述的参数创建一个计算属性:

    computed:{
       returnSvclinesValue(){
          return (code, name)=> {
           const svclinesTrimmedByName = svclines.find(i => i.label == name && i.value == name)
           const svclineValue = svclinesTrimmedByName.children.find(l => l.value == code )
           return svclineValue.label
         }
      }
    
    }
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多