2020-web前端-vue项目出错-[Vue warn]: Invalid prop: custom validator check failed for prop "index"

1.在写循环的时候遇见这个的

2020-web前端-vue项目出错-[Vue warn]: Invalid prop: custom validator check failed for prop "index&quot

2020-web前端-vue项目出错-[Vue warn]: Invalid prop: custom validator check failed for prop "index&quot

1.原因: index的值不能有空格,并且要为字符串类型

2.解决方法:加toString()这个方法

2020-web前端-vue项目出错-[Vue warn]: Invalid prop: custom validator check failed for prop "index&quot

2020-web前端-vue项目出错-[Vue warn]: Invalid prop: custom validator check failed for prop "index&quot

3.前方高能,(还是有一种,装13的方式),开始了

1.定义一个filters

js的代码:

filters: {
    numToString(value) {
      return value.toString()
    }
  },

2.在<template>里面引用filters

template代码:

:index="index | numToString"

2020-web前端-vue项目出错-[Vue warn]: Invalid prop: custom validator check failed for prop "index&quot

搞定!!!!!

4.终极版:架构师的方案:

1.先在common文件中新建一个common.js文件

2020-web前端-vue项目出错-[Vue warn]: Invalid prop: custom validator check failed for prop "index&quot

2.再在common.js,写入代码

export default {
  filters: {
    numToString(value) {
      return value.toString()
    }
  }
}

2020-web前端-vue项目出错-[Vue warn]: Invalid prop: custom validator check failed for prop "index&quot

3.然后再你需要的页面引入

import common from '@/common/mixins/common.js'

1.然后再讲引入到export default

export default {
  mixins: [common],
}

2020-web前端-vue项目出错-[Vue warn]: Invalid prop: custom validator check failed for prop "index&quot

还是一样的完美,豪横

上一篇:RTOS 和中断之间要注意的


下一篇:Weekly linux and ConferenceByYear(2002-now)