What is the correct way to introduce a common library using vue?

I am developing a project with nuxt.js.

I unify the common js into the utility class / util.js

then I
import {loadScript} from"~ / util"

in each vue page

as a result, it is found that each vue is completely packaged with util.js, instead of just loadScript.

excuse me, why is this?

Apr.19,2021

individual export methods are:
export function loadScript () {}
or

function loadScript(){}
export {loadScript}

you can post the export of util.


change utils.js to a folder, and then store it according to the file.

import loadScript from '~/util/loadScript'
Menu