hi, p> https://codesandbox.io/s/yv1zpj874x P> actions / index.js strong> p> asyncvalidationform.js strong> p> update1: Maintenant, seule cette erreur a été supprimée forte>
https://codesandbox.io/s/4JPKK394x7?modulteview=1 P > https://codesandbox.io/s/pjj6m1l9pq p> asyncvalidationform.js strud> p> steppleplate.js strong> p>
Une erreur d'origine croisée a été lancée. Réagir n'a pas accès à l'objet d'erreur réel dans le développement. Voir b.me/react-crossorigin-Error pour plus d'informations. Code> Li>
console.log ("asyncvalidationform this.props ------->", cela.props); code> li> li>
<Button
variant="contained"
color="primary"
onClick={onNext}
className={classes.button}
>
{canGoBack ? "Next" : "go to next step"}
</Button>
3 Réponses :
Ceci est un code simple pour activer un bouton sur le bouton radio click Si vous voulez un plus de descriptif, il vous plaît élaborer votre question
p>
<html> <script> function enableButton() { document.getElementById("button").disabled = true; } </script> <input type="radio" name="gender" value="male" onclick="JaaScript:enableButton()"> Male<br> <button type="button" id="button">Click Me!</button> </html>
Hey in asyncvalidationform.js j'ai ajouté le bouton radio Pouvez-vous ajouter des événements clics là-bas .... Pour que cela m'aidera à continuer .... Pouvez-vous mettre à jour dans mon bac à sable directement
J'ai essayé dans mon bac à sable, sa ne fonctionne pas ... Pouvez-vous mettre à jour dans mon bac à sable
La première chose que vous devrez faire est de supprimer la référence à à p>
Les composants fonctionnels héritent de leur contexte fonctionnel de la portée de la fonction mère et n'ont pas de Voici une version fourchue ou votre carte de code que j'ai commencé à référer ... p>
https://codesandbox.io/s/4jpkk394x7?modulteview=1 p>
et de fond sur des composants fonctionnels (apatrides) VS CLASS (Etatful) ... P>
https://programmingwithmosh.com/reac/reac-fonctions-Components/ a> p> de ce code> de votre composant fonctionnel em> ... p>
onclick = {this.passradialue ("droite")} code> p>
onclick = {passradioalue ("droite")} code> p>
cet objet code>. Cela supprimera les erreurs immédiates p>
hey mais le bouton d'aller à l'étape suivante doit activer uniquement après avoir sélectionné l'option dans le bouton radio, pouvez-vous m'aider avec ça
Yup, c'était ma prochaine question pour vous. Je vais devoir vous aider demain cependant. Désolé, déconnecter pour la nuit
Ok merci ... quand vous mettez à jour pouvez-vous mettre à jour avec les commentaires
Hey eu occupé? Peux-tu aider s'il te plait
Je vais devoir revenir plus tard ce soir à ce soir, mais je vais certainement prendre un coup de poignard à ce moment-là.
Salut, malchance. Ce serait génial si vous me laissez savoir dès que possible
Pouvez-vous m'aider avec le problème du redux aussi
https://codesandbox.io/s/6zrw7r66rr
J'ai fourré votre codesandbox et éditez 4 fichiers. À peu près sûr, il répond à toutes vos exigences énoncées ci-dessus P>
VerticallineErStepper.js: C'est ici que nous stockons notre nom d'utilisateur in asyncvalidationform.js code>, nous lions puis, dans ceci est Voici le correctif de la ré-rendu:
https://codesandbox.io/s/vqvxj7ky4y
Mise à jour Nom d'utilisateur, mot de passe, désactivé (Radiobutton) code> état et
HandLechange Code > Méthode pour
SetState code>. Ensuite, nous avons transmis l'état à ->
step1.js code> ->
asyncvalidationform.js code>. P>
Onchange code> pour suivre la valeur et appeler la méthode
setState code> et
ceci.props.handlechange code> Pour
setState code> dans
verticallinearsepper.js code> p>
steppleplate.js code> Ajouter désactivéNext, checkdisabledNext code> accessoires.
CheckDisableDNexgère Code> Pour déterminer si le bouton Suivant aura une vérification conditionnelle ou non.
désactivéNexTe code> est la valeur désactivée. p>
step1.js code>, nous passons ici des accessoires à
Steptemplate code> et
asyncvalidationform code>: p>
verticallineeepper.js code>, alors nous n'avons plus besoin de fichier step1.js, puisque nous écrivons le contenu de STEP1.JS dans ce fichier: P>
import React from "react";
import PropTypes from "prop-types";
import { withStyles } from "@material-ui/core/styles";
import Stepper from "@material-ui/core/Stepper";
import Step from "@material-ui/core/Step";
import StepLabel from "@material-ui/core/StepLabel";
import StepContent from "@material-ui/core/StepContent";
import Button from "@material-ui/core/Button";
import Paper from "@material-ui/core/Paper";
import Typography from "@material-ui/core/Typography";
// import Step1 from "./steps/Step1";
import Step2 from "./steps/Step2";
import Step3 from "./steps/Step3";
import StepTemplate from "./steps/StepTemplate";
import AsyncValidationForm from "./forms/AsyncValidationForm";
const styles = theme => ({
root: {
width: "90%"
},
button: {
marginTop: theme.spacing.unit,
marginRight: theme.spacing.unit
},
actionsContainer: {
marginBottom: theme.spacing.unit * 2
},
resetContainer: {
padding: theme.spacing.unit * 3
}
});
class VerticalLinearStepper extends React.Component {
state = {
activeStep: 0,
//we set our state in this parent
disabledNext: true,
username: "",
password: ""
};
steps = {
//we pass the content of Step1 here, so we dont have to pass props
"Select campaign settings": props => (
<StepTemplate
text={`
For each ad campaign that you create, you can control how much you're
willing to spend on clicks and conversions, which networks and
geographical locations you want your ads to show on, and more.
For each ad campaign that you create, you can control how much you're
willing to spend on clicks and conversions, which networks and
geographical locations you want your ads to show on, and more.
For each ad campaign that you create, you can control how much you're
willing to spend on clicks and conversions, which networks and
geographical locations you want your ads to show on, and more.
For each ad campaign that you create, you can control how much you're
willing to spend on clicks and conversions, which networks and
geographical locations you want your ads to show on, and more.
For each ad campaign that you create, you can control how much you're
willing to spend on clicks and conversions, which networks and
geographical locations you want your ads to show on, and more.
For each ad campaign that you create, you can control how much you're
willing to spend on clicks and conversions, which networks and
geographical locations you want your ads to show on, and more.
For each ad campaign that you create, you can control how much you're
willing to spend on clicks and conversions, which networks and
geographical locations you want your ads to show on, and more.
For each ad campaign that you create, you can control how much you're
willing to spend on clicks and conversions, which networks and
geographical locations you want your ads to show on, and more.
For each ad campaign that you create, you can control how much you're
willing to spend on clicks and conversions, which networks and
geographical locations you want your ads to show on, and more.
For each ad campaign that you create, you can control how much you're
willing to spend on clicks and conversions, which networks and
geographical locations you want your ads to show on, and more.
For each ad campaign that you create, you can control how much you're
willing to spend on clicks and conversions, which networks and
geographical locations you want your ads to show on, and more.
For each ad campaign that you create, you can control how much you're
willing to spend on clicks and conversions, which networks and
geographical locations you want your ads to show on, and more.
`}
//we want to apply checking on Step1.js, so we add checkDisabledNext attribute
checkDisabledNext={true}
disabledNext={this.state.disabledNext} //use this class' state
{...props}
>
<form>
form for the first step here
<div>test here</div>
<AsyncValidationForm
onSubmit={values => {
console.log(values);
alert(
`Values: username: ${values.username} password: ${
values.password
}`
);
}}
//we use this class setstate , no need to pass down props
handleChangeDisabledNext={this.handleChangeDisabledNext}
disabledNext={this.state.disabledNext}
handleChange={this.handleChange}
username={this.state.username}
password={this.state.password}
/>
</form>
</StepTemplate>
),
"Create an ad group": Step2,
"Create an ad": Step3
};
//setState for disabledNext
handleChangeDisabledNext = value => {
this.setState({ disabledNext: value });
};
//setState for username, password
handleChange = (name, value) => {
this.setState({ [name]: value });
};
stepsCount = () => Object.values(this.steps).length;
canGoBack = () => this.state.activeStep > 0;
canGoForward = () => this.state.activeStep < this.stepsCount();
isFinished = () => this.state.activeStep === this.stepsCount();
handleBack = () => {
if (this.canGoBack()) {
this.setState(prevState => ({ activeStep: prevState.activeStep - 1 }));
}
};
handleNext = () => {
if (this.canGoForward()) {
this.setState(prevState => ({ activeStep: prevState.activeStep + 1 }));
}
};
handleReset = () => this.setState({ activeStep: 0 });
render() {
const { classes } = this.props;
const { activeStep } = this.state;
return (
<div className={classes.root}>
<Stepper activeStep={activeStep} orientation="vertical">
{Object.entries(this.steps).map(([label, CustomStep]) => (
<Step key={label}>
<StepLabel>{label}</StepLabel>
<StepContent>
<CustomStep
canGoBack={this.canGoBack()}
canGoForward={this.canGoForward()}
onBack={this.handleBack}
onNext={this.handleNext}
classes={classes}
/>
</StepContent>
</Step>
))}
</Stepper>
{this.isFinished() && (
<Paper square elevation={0} className={classes.resetContainer}>
<Typography>All steps completed - you're finished</Typography>
<Button onClick={this.handleReset} className={classes.button}>
Reset
</Button>
</Paper>
)}
</div>
);
}
}
VerticalLinearStepper.propTypes = {
classes: PropTypes.object
};
export default withStyles(styles)(VerticalLinearStepper);
Les commentaires ne sont pas pour une discussion prolongée; Cette conversation a été
@Alvin pour conserver la valeur de la zone de texte votre utilisation Nom d'utilisateur: "", code> mais comment retenir les valeurs de bouton radio
@nossr n'ajoute plus de commentaires, nous pouvons utiliser le chat
Votre sable de sable devrait être un exemple minimal . Si les extraits ci-dessus sont le code correspondant, il ne devrait pas y avoir presque rien d'autre dans votre bac à sable.
@Ryancogswell hey j'ai enlevé les fichiers inutilisés, pouvez-vous m'aider maintenant
La bac à sable ne me semble pas différente.
Hey j'utilise pas à pas et réduisez la forme afin que ces codes soient là ... Je ne sais pas comment reproduire en supprimant ces codes ... Pouvez-vous me faire savoir
@Ryancogswell j'ai essayé dans ma boite de sable, sa ne fonctionne pas ... Pouvez-vous mettre à jour dans mon bac à sable
@nossr Je pense que la réponse n'est plus verrouillée.