router文件中使用vue的h方法渲染页面
2021-04-10 本文已影响0人
曾祥辉
直接上代码
//router.ts
import { createWebHashHistory, createRouter } from 'vue-router';
import { h } from 'vue';
const history = createWebHashHistory();
import index from '@/views/index.vue';
export const router = createRouter({
history,
routes: [
{
path: '/home',
component: h(index, key: 'index'})
}
]
}
h是vue渲染虚拟DOM的方法