vue3使用defineAsyncComponent报错
<!DOCTYPE html>
<html>
<head>
<title>Vue3 defineAsyncComponent Example</title>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>
<body>
<div id="app">
<async-component></async-component>
</div>
<script type="module">
const { defineAsyncComponent, createApp } = Vue;
const ArticleList = defineAsyncComponent(() => import("./hello.vue"));
console.log(ArticleList);
let app = createApp({});
app.component("AsyncComponent",ArticleList)
app.mount("#app");
</script>
</body>
</html>
//hello.vue ·```javascript
<template>
<h3>{{a}}</h3>
</template>
<script >
export default{
data() {
return {
a:0
}
},
}
</script>
``` 组件
<template>
<h3>{{a}}</h3>
</template>
<script >
export default{
data() {
return {
a:0
}
},
}
</script>
推荐文章: