简体   繁体   English

Vue.js过滤器不适用于特殊字符

[英]Vue.js filrter not works with special character

I have a filter witch looks inside a items: {} array, this array have 26 objects inside. 我有一个过滤器,它在一个items: {}内查找items: {}数组,该数组内部有26个对象。 The object 24 have an alias with special character ñ . 对象24具有特殊字符ñ的别名。 The filter not works on this object and the next ones until the end of the items array. 直到items数组的末尾,过滤器才对这个对象和下一个对象起作用。

items: {
    [...]
    23: {
      alias: "Correcto",
      id: 11
    },
    24: {
      alias: "Tamaño",
      id: 12
    }
    25: {
      alias: "silla",
      id: 13
    }
};

This is the code of my filter as a computed: porperty 这是我的过滤器的computed:代码computed: porperty

computed: {
      filteredItems() {
          if (this.items) {
              return this.items.filter((item) => {
                  if (!this.search) return '';
                  return item.alias.toLowerCase().match(this.search.toLowerCase().trim());
              });
          }
      }
  },

How can i make the filter works with any type of characters? 如何使过滤器适用于任何类型的字符?

You need to use the correct encoding. 您需要使用正确的编码。 This library offers a plugin to support a wide range of varying language formats. 库提供了一个插件,以支持多种不同的语言格式。

Unicode would give you a consistent and widely supported base. Unicode将为您提供一致且广泛支持的基础。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM