In this part, we will create the <script> section of the single file component. Follow these instructions to create the component correctly:
- Open App.vue in the src folder.
- Import each one of the components that will be created here:
import List from './components/list';
import Create from './components/create';
import View from './components/view';
import Update from './components/update';
- In the data property, create two new values: componentIs with a default value of 'list', and userId with a default value of 0:
data: () => ({
componentIs: 'list',
userId: 0,
}),
- We need to add a new property to the Vue object, called provide. This property will be a function, so the provided values to the components can be reactive:
provide () {
const base = {};
Object.defineProperty(base, 'userId', {
enumerable: true,
get: () => Number(this.userId),
});
return...