filters过滤器的使用(结合switch)

filters:

    text(val) {

      var text = "";

      switch (val - 0) {

        case 0:

          text = "一";

          break;

        case 1:

          text = "二";

          break;

        case 2:

          text = "三";

          break;

        case 3:

          text = "四";

          break;

        case 4:

          text = "五";

          break;

        case 5:

          text = "六";

          break;

        case 6:

          text = "七";

          break;

        case 7:

          text = "八";

          break;

        case 8:

          text = "九";

          break;

        case 9:

          text = "十";

          break;

      }

      return text;

    },

  },


在模板中使用:

{{ index | text }}

在methods方法中的使用:

this.$options.filters['text'](i)


https://www.cnblogs.com/zsj-02-14/p/15098839.html

你可能感兴趣的:(filters过滤器的使用(结合switch))