[Vuejs]-Require a js method for Nuxt page methods

1👍

Something like this:

lib/api.js

const loadStuff = async (params) => {...};
export { loadStuff };

components/widget.vue

import { loadStuff } from '~/lib/api';

Note that the ~/lib/api path will vary depending on the file name and your build environment. E.g. it could be @/lib/api.

Leave a comment