Invalid prop: type check failed for prop "name". Expected String with value "17", got Number with va

1、错误描述

vue.runtime.esm.js:631 [Vue warn]: Invalid prop: type check failed for prop "name". Expected String with value "17", got Number with value 17.

found in

--->  at packages/checkbox/src/checkbox.vue
        at packages/form/src/form-item.vue
         
           
              at packages/form/src/form.vue
                at packages/dialog/src/component.vue
                  at src/views/org/index.vue
                    at src/layout/components/AppMain.vue
                      at src/layout/index.vue
                        at src/App.vue
                         
warn @ vue.runtime.esm.js:631
vue.runtime.esm.js:631 [Vue warn]: Invalid prop: type check failed for prop "name". Expected String with value "18", got Number with value 18.

found in

--->  at packages/checkbox/src/checkbox.vue
        at packages/form/src/form-item.vue
         
           
              at packages/form/src/form.vue
                at packages/dialog/src/component.vue
                  at src/views/org/index.vue
                    at src/layout/components/AppMain.vue
                      at src/layout/index.vue
                        at src/App.vue
                         

2、错误原因

     由于el-checkbox中的属性name需要字符串类型,而后台传过来的是数字类型,导致类型不匹配,出现报错


  
    
  • {{ item.name }}移除

3、解决办法

     编写一个过滤器,将数值类型转换成字符串


  
    
  • {{ item.name | numToStr }}移除
export function numToStr(num) {
  num = num.toString()
  return num
}

 

你可能感兴趣的:(Vue.js)