Home > Web Front-end > JS Tutorial > body text

How to set the webpack file alias and configure the default class of routing in vue

一个新手
Release: 2017-09-27 10:26:28
Original
1979 people have browsed it

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')
    }
  },
Copy after login

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: [
   ]
})
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template