Home >Web Front-end >JS Tutorial >How to set the webpack file alias and configure the default class of routing in vue
Last time when I was studying, I encountered the problem of configuring the default route. This time we configured the webpack file alias and set the default class for the route
1. Set the webpack file alias
First set the alias in the webpack.base.conf.js file. Find
resolve: { extensions: ['.js', '.vue', '.json'], alias: { 'vue$': 'vue/dist/vue.esm.js', '@': resolve('src'), 'components': resolve('src/components') } },
and configure it in alias.
If your file is in components;
When setting, you can write it as my above resolve('src/components '). When introducing the files under this file, just components/** directly.
This is very simple.
2. Configure the default class of routing
This is also a very simple configuration. There is also an explanation in the vue-router documentation.
When I configured it. Set the default routing class to active. After all, the default one is too long. The configuration is as follows:
export default new Router({ linkActiveClass: 'active', routes: [ ] })
The key point is linkActiveClass: 'active', which is the new routing default class set.
This way you can use active directly when writing code. Isn’t it a lot more convenient?
The above is the detailed content of How to set the webpack file alias and configure the default class of routing in vue. For more information, please follow other related articles on the PHP Chinese website!