0
Vue 앱을 만들고 있습니다. 폼의 버튼을 클릭하면 값이 paypal
인 입력을 채우고 양식을 제출합니다. 그러나 test_form.php
(양식의 파일 작업)에서 $_POST['paymentMethod']
변수는 paypal
대신 null
을 포함합니다! 내가 틀린 곳?Vue에서 필드를 채운 후에 폼을 제출하는 것
HTML :
<form action="test/test_form.php" method="POST" ref="form">
<button type="button" v-on:click="setMethod('cc')">Credit card</button>
<button type="button" v-on:click="setMethod('paypal')">Paypal</button>
<input type="text" name="paymentMethod" required v-model="selectedMethod">
</form>
자바 스크립트 :
new Vue({
el: "#app",
data: {
selectedMethod: null,
},
methods: {
// Set payment
setMethod: function(type) {
this.selectedMethod = type; // Here I fill the field
this.$refs.form.submit(); // Then I submit the form
},
}
});
방금 readonly 특성을 제거했지만 문제가 지속됩니다. 질문을 좀 더 명확하게 업데이트했습니다. –
'nextTick' 사용에 대한 답변을 볼 수 있습니다. – PatrickSteele
감사합니다 패트릭! 내가 틀렸기 때문에 답의 첫 부분을 제거하는 것이 좋습니다 => https://stackoverflow.com/a/16438237/1252920 –