In this part, we will create the <script> section of the single file component. Follow these instructions to create the component correctly:
- Move the create.vue file from components to the views folder, and rename it Create.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],
- On the getUserById method, we need to remove ${window.location.href} from the postHttp function URL and change the changeComponent functions to changeRoute:
async createUser() {
await postHttp(`/api/users`, {
data: {
...this.userData,
}
});
this.changeRoute('list');
},