我正在寻找一种在 Angular 2 中的特定位置(鼠标事件 x/y)添加 div 组件的方法。
https://jsfiddle.net/lennartquerter/w2c7uqw6/
this.xPos = xPos;
this.yPos = yPos;
我将位置传递到我的拒绝类中,但我不知道如何从中制作样式?我检查了 Angular 文档,但我只能设置 bool 值和固定的 css 值/类。我想做这样的事情:
[style]="rejectPosition"
this.rejectPosition = "left: "+ this.xPos + "px ; top: "+ this.yPos + "px;"
但这是不可能的。 是否有 Angular 2 方法可以做到这一点?
我找到了一种不用 reject Component 的方法,它只是用 jQuery 内嵌样式,但我不喜欢这种方法。
最佳答案
[style.left.px]="xPos" [style.top.px]="yPos"
关于css - Angular 2-Jquery |使用鼠标位置添加样式(顶部/左侧),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37372745/