4Manuals

  • PDF Cloud HOME

属性数据库查询-找不到userFunction Download


我正在尝试遵循these instructions来查询模型的属性数据库。在本地开发服务器上进行测试时,一切正常,但是当我将其部署到Firebase时,出现此错误:

Uncaught (in promise) {msg: "function 'userFunction' was not found."}

下面是我的代码:

const viewerHelperPlugin = {
install(Vue){
Vue.prototype.$viewerHelper = {
  getElementsByPropertyValue: function (viewer, propertyName, propertyValue, operator) {
    return new Promise(function(resolve, reject) {
      function userFunction (pdb, userData) {
        var attrIndex = -1;
        // Iterate over all attributes and find the index to the one we are interested in
        pdb.enumAttributes(function(i, attrDef, attrRaw){
          var name = attrDef.name;
          if (name === userData.propertyName) {
              attrIndex = i;
              return true; // to stop iterating over the remaining attributes.
          }
        });
        // Early return is the model doesn't contain data.
        if (attrIndex === -1)
          return [];

        var returnElements = [];

        pdb.enumObjects(function(dbId) {
          // For each part, iterate over their properties.
          pdb.enumObjectProperties(dbId, function(attrId, valId){
            if (attrId === attrIndex) {
              var value = pdb.getAttrValue(attrId, valId);
              if (userData.operator === "==" && value === userData.propertyValue) {
                  returnElements.push(dbId);
              }
              else if (userData.operator === ">" && value > userData.propertyValue) {
                returnElements.push(dbId);
              }
              else if (userData.operator === ">=" && value >= userData.propertyValue) {
                returnElements.push(dbId);
              }
              else if (userData.operator === "<" && value < userData.propertyValue) {
                returnElements.push(dbId);
              }
              else if (userData.operator === "<=" && value <= userData.propertyValue) {
                returnElements.push(dbId);
              }
              else if (userData.operator === "!=" && value != userData.propertyValue) {
                returnElements.push(dbId);
              }
            }
          });
        });
        return returnElements;
      }
      var thePromise = viewer.model.getPropertyDb().executeUserFunction( userFunction, 
{propertyName: propertyName, propertyValue: propertyValue, operator: operator } );
      thePromise.then(function(retValue){
        resolve(retValue);
      });
    });
  }
}

} }

我不确定为什么为什么找不到该函数,因为我在语句上方立即声明了该函数。

0 个答案:

没有答案



Similar searches
    我无法在AspnetBoilerplate模板5.0中创建和更新角色 通过api下载checkmarx ProjectState报告 智利实体未插入具有onetomany的父实体更新 Samsung SR-34RMB Refrigerator User Manual 如何在R中为轴参数指定标签长度。我的标签名称被截断