zoukankan      html  css  js  c++  java
  • go.js remove 特定part

    我想删除一个实际上是背景的部分。

    假设这是我添加part的方式

    myDiagram.add(
      scope.gj(go.Part,//此Part未绑定到任何模型数据
    { 
      layerName:“Background”,position:new go.Point(0,0),
      selectable:false,pickable:false ,name:'特定name'
    } ,
    scope.gj(go.Picture,{ 
    source:img.src,
    // width:scope.totalDiagramWidth,
    // height:scope.totalDiagramHeight 
    },
    new go.Binding(“width”,“widthOfCanvas”),
    new go。绑定(“height”,“heightOfCanvas”)
    )
    ))

    现在我想删除它

    在添加时,加上特定name,然后根据name查找到改part

    function findPart(name) {
      var it = myDiagram.parts;
      while (it.next()) {
        if (it.value.name === name) return it.value;
      }
      return null;
    }
    let part = findPart('Background1')
    if(part){
    myDiagram.remove(part)
    }
     
  • 相关阅读:
    luogu 1593
    luogu 1369
    hdu 1796
    bzoj 3398
    luogu 4587
    luogu 2152
    bzoj 3629
    bzoj 1507: [NOI2003]Editor
    bzoj 1503: [NOI2004]郁闷的出纳员
    bzoj 1497: [NOI2006]最大获利
  • 原文地址:https://www.cnblogs.com/gxp69/p/10414228.html
Copyright © 2011-2022 走看看