【问题标题】:spfx - onpropertychange eventspfx - onpropertychange 事件
【发布时间】:2019-07-05 04:44:38
【问题描述】:

我创建了级联下拉菜单。我需要根据父下拉选择加载下拉列表。我正在尝试使用 onpropertychange 事件。但我在 super.onpropertychange 上遇到错误,说 {Property 'onPropertyChange' 在类型 'BaseClientSideWebPart' 上不存在。}

请告诉我们我错过了什么。

 protected onPropertyChange(propertyPath: string, newValue: any):void{  
    if(propertyPath === "listDropDown"){  
      // Change only when drop down changes  
      super.onPropertyChange(propertyPath,newValue);  
      // Clears the existing data  
      this.properties.ItemsDropDown = undefined;  
      this.onPropertyChange('ItemsDropDown', this.properties.ItemsDropDown);  
      // Get/Load new items data  
      this.GetItems();  
    }  
    else {  
      // Render the property field  
      super.onPropertyChange(propertyPath, newValue);  
    }  
  }  

【问题讨论】:

    标签: spfx


    【解决方案1】:

    不是onPropertyChange,也许您的意思是来自BaseWebPart 类的onPropertyFieldChanged

    错误消息是准确的 - Web 部件没有名为 onPropertyChange 的方法。以上听起来像是您尝试做的最接近的匹配。请注意,它需要三个参数,而不是两个参数:propertyPatholdValuenewValue

    【讨论】:

      猜你喜欢
      • 2012-12-10
      • 1970-01-01
      • 2012-02-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-14
      • 2010-10-29
      相关资源
      最近更新 更多