runtime-core.esm-bundler.js:38 [Vue warn]: Component provided template option but runtime compilation is not supported in this build of Vue. Configure your bundler to alias "vue" to "vue/dist/vue.esm-bundler.js".
at <Anonymous onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< undefined > >
at <RouterView>
at <App>
可能出错的代码片段
const Home = { template: '<div>Home</div>' }
const routes = [
{ path: '/', component: Home}
]
解决方法:
在vite.config.js文件中配置resolve.alias
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'vue': 'vue/dist/vue.esm-bundler.js'
}
}
})
或者将
const Home = { template: '<div>Home</div>' }
改为单文件
import Home from './Home.vue'