app.vue
<template>
<button @click="handleClick">点击异步加载函数</button>
</template>
<script>
export default {
setup() {
const handleClick = async () => {
const { asyncFn } = await import("./utils/index.js");
asyncFn();
};
return {
handleClick,
};
},
};
</script>
./utils/index.js
export const asyncFn = async () => {
console.log("异步加载函数");
};