How to use vue3/vue router correctly?

294 Views Asked by At

I had some problems trying out the vue3.

router is my custom.

import router from './router'

when i write

createApp(App).use(Antd,VueAxios,axios,qs,router).mount('#app')

The page does not load the correct page.Vue Router Looks like not working but when i write

createApp(App).use(router,Antd,VueAxios,axios,qs).mount('#app')

it's working! So why?

code:https://github.com/fangminghui/app_h5

1

There are 1 best solutions below

0
On BEST ANSWER

app.use or createApp(App).use doesn't accept multiple plugin as parameters, it accepts only the plugin and its options if there's options :

createApp(App).use(thePlugin,options)

if you want to use multiple ones you should chain multiple .use like :

createApp(App).use(qs).use(router).use(VueAxios).use(Antd).mount('#app')