Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

properties打印出来为proxy对象 #530

Closed
towersxu opened this issue Mar 15, 2022 · 3 comments
Closed

properties打印出来为proxy对象 #530

towersxu opened this issue Mar 15, 2022 · 3 comments
Labels

Comments

@towersxu
Copy link
Collaborator

image

@towersxu towersxu added the FAQ label Mar 15, 2022
@towersxu
Copy link
Collaborator Author

towersxu commented Mar 15, 2022

在自定义model的时候,如果直接通过this.properties在model中获取properties属性,会显示为Proxy对象。这是因为LogicFlow内部为了让properties发生变化后能实时更新流程图,所以把properties转换为响应式对象。如果要打印原生对象内容,可以使用model的getProperties方法获取。

class UserTaskModel extends RectNodeModel {
  getNodeStyle() {
    const style = super.getNodeStyle();
    const properties = this.getProperties();
    if (properties.statu === 'pass') {
      style.stroke = "green";
    } else if (properties.statu === 'reject') {
      style.stroke = "red";
    } else {
      style.stroke = "rgb(24, 125, 255)";
    }
    return style;
  }
}

PS: proxy对象虽然打印出来无法看到属性,但是在控制台上继续展开也可以看到属性。同时,这些属性可以仍然可以正常的通过属性操作符得到。上面的代码和下面的结果一致:

class UserTaskModel extends RectNodeModel {
  getNodeStyle() {
    const style = super.getNodeStyle();
    if (this.properties.statu === 'pass') {
      style.stroke = "green";
    } else if (this.properties.statu === 'reject') {
      style.stroke = "red";
    } else {
      style.stroke = "rgb(24, 125, 255)";
    }
    return style;
  }
}

@lengthy-daydream
Copy link

statu这个属性是写在哪里的?

@towersxu
Copy link
Collaborator Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants