【问题标题】:A-Frame: Default value 'true' does not match type 'boolean' in browser.jsA-Frame:默认值“真”与 browser.js 中的“布尔”类型不匹配
【发布时间】:2017-08-13 01:09:28
【问题描述】:

我已经为此奋斗了一段时间。控制台似乎填充了不正确的匹配类型,而实际上它得到了正确的类型。

    Default value `true` does not match type `boolean` in component `nav-panel`
    Default value `false` does not match type `boolean` in component `nav-panel` 
    Default value `0` does not match type `number` in component `nav-button` 

看到这种情况确实很烦人。

【问题讨论】:

    标签: three.js components aframe


    【解决方案1】:

    这里的问题是这些默认值是字符串值,它们本身并没有在它们的类型中定义。

    在架构中定义时,如果您有数字或布尔值,则它们不能用引号括起来 ""(如果这样做,您就是在告诉 A-Frame 这些是字符串!)

    这意味着:

    把“真”改成真,把“0”改成0:

    AFRAME.registerComponent('nav-panel', {
     schema : {
      active: {type: "boolean", default: "true"},  
      textOffset: {type: 'number', default: '0'},
    
     },
    
    }
    

    正确:

    AFRAME.registerComponent('nav-panel', {
     schema : {
      active: {type: "boolean", default: true},  
      textOffset: {type: 'number', default: 0},
    
     }
    }
    

    【讨论】:

      猜你喜欢
      • 2013-12-22
      • 1970-01-01
      • 2011-11-20
      • 1970-01-01
      • 1970-01-01
      • 2011-08-28
      • 2019-01-12
      • 2014-12-30
      • 1970-01-01
      相关资源
      最近更新 更多