Ich versuche also, die Paypal-Taste auf meiner App angezeigt zu bekommen, aber ich kann es nicht funktionieren. Ich basiere es von diesem Spiel ab. https://jsfiddle.net/rbacekkb/Paypal Button für react.js
Ich habe versucht, in meine App zu setzen, aber der Button wird nicht auf der Seite angezeigt, die ich möchte. Ich weiß nicht, was ich falsch gemacht habe.
paypal.jsx
import React from 'react';
class PayPalButton extends React.Component {
constructor() {
super();
// you can take this value from a config.js module for example.
this.merchantId = '6XF3MPZBZV6HU';
}
componentDidMount() {
let container = this.props.id;
let merchantId = this.merchantId;
window.paypalCheckoutReady = function() {
paypal.checkout.setup(merchantId, {
locale: 'en_US',
environment: 'sandbox',
container: container,
});
}
}
render() {
return(
<a id={this.props.id} href="/checkout" />
);
}
}
module.exports = PayPalButton;
versuchen, es auf dieser Seite zur Zeit zum Testen zeigen.
home.jsx
import React from "react";
import {Grid,Row,Col,Button,Jumbotron, Carousel, Panel} from "react-bootstrap";
import PayPalButton from "../components/paypal";
import {LinkContainer} from 'react-router-bootstrap';
import {Link} from 'react-router';
const title = (
<h3>Fashion News</h3>
)
const title2 = (
<h3>Fashion History</h3>
)
const title3 = (
<h3>Fashion Items</h3>
)
const Home = React.createClass({
displayName: "Home page",
componentDidMount(){
console.log(this.props)
},
render(){
return (
<PayPalButton id="button" />
);
}
});
module.exports = Home;
index.html
<script>
(function(){
var ef = function(){};
window.console = window.console || {log:ef,warn:ef,error:ef,dir:ef};
}());
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv-printshiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/es5-shim/3.4.0/es5-shim.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/es5-shim/3.4.0/es5-sham.js"></script>
<script src="react-with-addons-15.1.0.js"></script>
<script src="react-dom-15.1.0.js"></script>
<script src="//www.paypalobjects.com/api/checkout.js" async></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.38/browser.js"></script>
1) Verwenden Sie keine IDs in React-Komponenten! 2) Ihr Anker schließt sich selbst, so dass er nicht erscheint. – Li357