vue2.0 在v-for中传递index获取计算值

vue版本:2.2.4

title要获取根据index获取不同的值时,如果使用computed,不能获取到index,所以要使用methods

methods: {
    title(index) {
      switch (index) {
        case 0:
          return '失败';
        default:
          return '结果:' + index;
      }
    }
  },

你可能感兴趣的:(vue2.0 在v-for中传递index获取计算值)