add useRouter

master
Andreas Zweili 2021-09-06 12:57:45 +02:00
parent 088430e2fb
commit 52dc4c0128
1 changed files with 12 additions and 5 deletions

View File

@ -12,7 +12,11 @@
</div>
<div>
<label for="description">Description</label>
<textarea rows="5" id="description" v-model="enteredDescription"></textarea>
<textarea
rows="5"
id="description"
v-model="enteredDescription"
></textarea>
</div>
<button>Add Product</button>
</form>
@ -21,9 +25,11 @@
<script>
import { ref, inject } from 'vue';
import { useRouter } from 'vue-router';
export default {
setup() {
const router = useRouter();
const addProduct = inject('addProduct');
const enteredTitle = ref('');
@ -34,17 +40,18 @@ export default {
addProduct({
title: enteredTitle,
description: enteredDescription,
price: enteredPrice,
price: enteredPrice
});
router.push('/products');
}
return {
enteredTitle,
enteredPrice,
enteredDescription,
submitForm,
submitForm
};
},
}
};
</script>
@ -88,4 +95,4 @@ button:active {
background-color: #220031;
border-color: #220031;
}
</style>
</style>