In this part, we will create the <script> section of the single file component. Follow these instructions to create the component correctly:
- Move the update.vue file from src/components to the src/views folder and rename it Edit.vue.
- Remove the old changeComponent mixin import and import the new changeRoute mixin:
import changeRouteMixin from '@/mixin/changeRoute';
- At the Vue mixins property, we need to replace changeComponent with changeRoute:
mixins: [changeRouteMixin],
- Create a new computed property in the component object, with the userId property , which will return $route.params.id:
computed: {
userId() {
return this.$route.params.id;
},
},
- On the getUserById and updateUser methods, we need to remove
${window.location.href} from the getHttp and patchHttp function URLs and change the changeComponent functions to changeRoute:
methods: {
async getUserById() {
const { data } = await getHttp(`api/users/${this...