如何在反应原生导航器中传递参数?

时间:2017-05-07 08:15:09

标签: reactjs react-native react-navigation

我尝试了一个React Native Navigator的例子:

# 1. Construct the sparse matrix with numbers_of_occurrences
D = [d[1] for d in mydata]
v = DictVectorizer(sparse=True)
kmeans_data = v.fit_transform(D)
# 2. Normalize by computing sums for each row and dividing 
import numpy as np
sums = np.sum(kmeans_data,axis=1).A[:,0]
N = len(s)
divisor = csr_matrix((np.reciprocal(s),(range(N),range(N))))
kmeans_data = divisor*kmeans_data)

如何将参数传递给StudentStackNav并将其传递给StudentLogin?

我已尝试import UIKit class ViewController: UIViewController { var circle : Circle?; override func viewDidLoad() { super.viewDidLoad(); view.backgroundColor = UIColor.white; setupViews(); } func setupViews(){ circle = Circle(frame: self.view.frame); view.addSubview(circle!); circle?.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true; circle?.topAnchor.constraint(equalTo: view.topAnchor).isActive = true; circle?.heightAnchor.constraint(equalTo: view.heightAnchor).isActive = true; circle?.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true; } } class Circle : UIView{ override init(frame: CGRect) { super.init(frame: frame); self.backgroundColor = .blue; self.translatesAutoresizingMaskIntoConstraints = false; setupCircle(); } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } let gradientLayer = CAGradientLayer(); func setupCircle(){ layer.addSublayer(shapeLayer); let circlePath = UIBezierPath(arcCenter: CGPoint(x: self.frame.width / 2 - 50, y: self.frame.height / 2 - 50), radius: 50, startAngle: CGFloat(Double.pi * (0 / 4)), endAngle: CGFloat(Double.pi * 2), clockwise: true); shapeLayer.path = circlePath.cgPath; let group = CAAnimationGroup() group.animations = [animateStrokeEnd, animateOpacity] group.duration = 0.8 group.repeatCount = HUGE // repeat forver shapeLayer.add(group, forKey: nil) } let shapeLayer: CAShapeLayer = { let layer = CAShapeLayer(); layer.strokeColor = UIColor.white.cgColor; layer.lineWidth = 5; layer.fillColor = UIColor.clear.cgColor; layer.strokeStart = 0 layer.strokeEnd = 1; return layer; }(); let animateOpacity : CABasicAnimation = { let animation = CABasicAnimation(keyPath: "opacity"); animation.fromValue = 0; animation.toValue = 0.8; animation.byValue = 0.01; animation.repeatCount = Float.infinity; return animation }(); let animateStrokeEnd: CABasicAnimation = { let animation = CABasicAnimation(keyPath: "strokeEnd"); animation.fromValue = 0; animation.repeatCount = Float.infinity; animation.toValue = 1; return animation; }(); } const StudentStackNav = StackNavigator({ Home: { screen: StudentLogin, } }); 中未提供<StudentStackNav name='Lucy'>

1 个答案:

答案 0 :(得分:10)

导航器组件上的普通道具可用于配置导航器。

要向屏幕发送任意道具,您必须使用screenProps

例如:

<StudentStackNav screenProps={{ name: 'Lucy' }}/>

StudentLoginthis.props.screenProps将提供哪些内容。

screenProps记录在this page