In this part, we will create the <script> section of the single file component. Follow these instructions to create the component correctly:
- Create a new file called create.vue in the src/components folder and open it.
- Import the UserForm component, the changeComponent mixin, and postHttp from fetchApi:
import UserForm from './userForm';
import changeComponent from '../mixin/changeComponent';
import { postHttp } from '../http/fetchApi';
- It the data property, we will add a userData object with the name, email, birthday, country, and phone properties all defined as empty strings:
data: () => ({
userData: {
name: '',
email: '',
birthday: '',
country: '',
phone: '',
},
}),
- In the Vue mixins property, we need to add the changeComponent:
mixins: [changeComponent],
- In the Vue components property, add the UserForm component:
components: {
...