我试图通过非线性路径动画UIView(我不是试图绘制路径本身),如下所示:
视图的初始位置是使用尾部和底部约束(viewBottomConstraint.constant == 100
&viewTrailingConstraint.constant == 300
)确定的,我使用UIView.animatedWithDuration
如下:
viewTrailingConstraint.constant = 20
viewBottomConstraint.constant = 450
UIView.animateWithDuration(1.5,animation:{
self.view.layoutIfNeeded()
},completition:nil)
Run Code Online (Sandbox Code Playgroud)
但它以直线路径为视图制作动画.
我有一个像这样定义的组件
export class A extends Component{
constructor(props){
this.state = {
scene:0
}
}
static changeScene(scene){
this.setState({scene:scene})
}
}
Run Code Online (Sandbox Code Playgroud)
我想从任何地方调用更改场景A.changeScene(sceneVal)
来更改 A 中的场景。问题是我无法访问 this.setState 我收到此错误Unhandled JS Exception: this.setState is not a function.
我确定 A 组件已经安装。我可以通过var self = null;
在构造函数self = this
中定义全局变量和构造函数内部 来绕过这个错误,但我想要一个更好的方法来解决这个问题
我有两个组件A和B,其中组件A包含一个按钮.我希望当用户点击此按钮时,在组件B上触发一个功能
<A></A>
<router-outlet></router-outlet>
Run Code Online (Sandbox Code Playgroud)
并且组件B使用routing进行渲染.我正在考虑使用具有可观察布尔值的服务,该服务指示是否单击了A中的按钮.这是实现它的正确方法吗?
angular ×1
animation ×1
ecmascript-6 ×1
ios ×1
javascript ×1
react-native ×1
reactjs ×1
swift ×1
typescript ×1
uiview ×1