17定义局部过滤器

<el-tag :type="scope.row.hxTag | formatType">{{
  scope.row.hxTag
}}</el-tag>


filters: {
  formatType(value) {
    const tags = [
      { text: "单质", type: "" },
      { text: "氧化物", type: "success" },
      { text: "酸", type: "info" },
      { text: "碱", type: "warning" },
      { text: "盐", type: "danger" }
    ];
    return tags.find(e => e.text == value).type;
  }
}
原文地址:https://www.cnblogs.com/xiaoliziaaa/p/13138112.html