Reputation: 197
I created a project using Vite and added vue-router@next. I am using the router inside of the main.js as I've browsed around and seemed like this was the problem, however it does not fix the issue I am having.
// package.json
{
"name": "rng-alpha",
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"serve": "vite preview"
},
"dependencies": {
"vue": "^3.0.5",
"vue-router": "^4.0.5"
},
"devDependencies": {
"@vitejs/plugin-vue": "^1.1.5",
"@vue/compiler-sfc": "^3.0.7",
"vite": "^2.0.5"
}
}
// main.js
import { createApp } from 'vue';
import App from './App.vue';
import router from './router/router';
const app = createApp(App);
app.use(router);
app.mount('#app');
// router.js
import {
createWebHistory,
createRouter
} from 'vue-router'
import Home from '../components/Home.vue'
const routes = [{
path: "/",
name: "Home",
component: Home
}]
const router = createRouter[{
history: createWebHistory,
routes,
}]
export default router
// App.vue
<template>
<div>
<div>hi</div>
<router-view />
</div>
</template>
The warnings I am getting are the following:
How can I make the router-view work? Since I am not able to utilize it right now.
Upvotes: 3
Views: 5775
Reputation: 1
createRouter
is a method that should be called using ()
not []
:
const router = createRouter({
history: createWebHistory,
routes,
})
Upvotes: 3