Ich bin ziemlich neu zu programmieren und arbeiten am Lernen polymer.js. Im Moment arbeite ich gerade an einer einfachen Web-App, um einen Benutzer zu unterschreiben. Derzeit wird jedes Mal, wenn ich mein Formular abschicke, dieses Format wie unten gezeigt an ein komplettes JSON-Objekt übergeben.Submit Formularwerte in JSON-Objekt
{
email: "[email protected]",
password: "password"
}
statt ...
{
"email":"[email protected]",
"password":"password"
}
Hier ist mein Code:
<form action="http://httpbin.org/post" method="post">
<sign-in-input email="{{_email}}" password="{{_password}}"></sign-in-input>
<input class = "paperbtn" type="submit" value="Sign in">
<input name="email" value="[[_email]]" hidden>
<input name="password" value="[[_password]]" hidden>
</form>
sign-in-input.html:
<dom-module id="sign-in-input">
<template>
<paper-input label = "Email" id = "email" required></paper-input>
<paper-input label = "Password" id = "password" required></paper-input>
</template>
<script>
Polymer({
is: 'sign-in-input',
properties: {
email: {
type: String,
notify: true
},
password: {
type: String,
notify: true
}
},
listeners: {
'input': '_onInput'
},
_onInput: function() {
this.email = this.$.email.value.trim();
this.password = this.$.password.value.trim();
}
});
</script>
Ich sehe kein Problem. Sprichst du über den Abstand zwischen dem '' '' '' ''? Was macht das aus? – FrankerZ
Was ist die Frage? – Liam
Ich denke, das Problem ist 'email:" [email protected] "' sollte '" email "sein: "[email protected]" 'aber es ist nicht klar – Liam