I want to pass an URL parameter into the value of the input:
<input id="para" type=text v-model="recipient">
I have a URL with the param www.website.com?para=test , how can I inject that param on page loaded into the input?
I have done it with Jquery before, but I don't know how to achieve this in VUE. Here is the Jquery code that works:
<script>
$(document).ready(function() {
function getURLParameter(e) {
return decodeURI((new RegExp(e + "=(.+?)(&|$)").exec(location.search) || [, ""])[1]);
}
if (getURLParameter("Para") === "") {
console.log("No URL param value found.");
} else {
console.log(getURLParameter("Para"));
$("#para").value = getURLParameter("Para");
}
});
</script>
Thanks a lot