设置div元素的top属性

时间:2019-02-14 11:01:01

标签: javascript html angular typescript angular6

我想更改 div 元素的// load the mesh Eigen::MatrixXd V; Eigen::MatrixXi F; igl::readPLY("input.ply", V, F); pcl::PolygonMesh::Ptr polymesh (new pcl::PolygonMesh); pcl::PointCloud<pcl::PointXYZRGB>::Ptr mesh_cloud (new pcl::PointCloud<pcl::PointXYZRGB>); mesh_cloud->points.resize(V.rows()); for (int i=0; i<V.rows(); i++) { mesh_cloud->points[i].x = V(i, 0); mesh_cloud->points[i].y = V(i, 1); mesh_cloud->points[i].z = V(i, 2); } pcl::toPCLPointCloud2( *mesh_cloud, polymesh->cloud ); polymesh->polygons.resize(F.rows()); for (int i=0; i<F.rows(); i++) { polymesh->polygons[i].vertices.resize(3); polymesh->polygons[i].vertices[0] = F(i, 0); polymesh->polygons[i].vertices[1] = F(i, 1); polymesh->polygons[i].vertices[2] = F(i, 2); } pcl::visualization::PCLVisualizer viewer; viewer.setBackgroundColor (1, 1, 1); viewer.addPolygonMesh(*polymesh); viewer.spin(); top属性。

我尝试使用renderer2和方法left对其进行修改,但是没有运气。我的代码:

setProperty

如何修改这些属性?

1 个答案:

答案 0 :(得分:4)

尝试使用renderer.setStyle并使用nativeElement,而不是HTMLElement

还将px附加到您的值并将其从属性名称中删除:

this.renderer.setStyle(this.element.nativeElement, 'top', `${this.circle.center.y}px`);