[英]redirecting to different page with form submit in VUE JS
I am trying to submit form which will redirect to different page containing post request data .我正在尝试提交将重定向到包含发布请求数据的不同页面的表单。 Basically I hit redirectCompo component from another component
基本上我从另一个组件中点击了 redirectCompo 组件
return this.$router.push({path: '/form-submit-component'});
form submit component but it's not redirecting表单提交组件,但它没有重定向
<template>
<div style="visibility: hidden;">
<form name="PostForm" id="PostForm" method="POST" action="www.google.com">
<input type="text" name="email_id" value="xyz@gmail.com">
<input type="text" name="gender" value="male">
</form>
</div>
</template>
<script>
export default {
name: 'redirectCompo',
computed: {},
components: {},
data: function () {
return {}
},
mounted() { },
created() {
document.getElementById("PostForm").submit();
},
methods: {},
}
</script>
<template>
<div>
<form name="PostForm" id="PostForm" method="POST" action="www.google.com">
<input type="text" name="email_id" value="xyz@gmail.com" />
<input type="text" name="gender" value="male" />
<button type="submit">submit</button>
</form>
</div>
</template>
<script>
export default {
name: "redirectCompo",
computed: {},
components: {},
created() {
this.submit();
},
methods: {
submit() {
console.log("form has been submitted");
this.$router.push({ path: "/home" });
},
},
data: function () {
return {};
},
};
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.