两种方法,第一种是理解和阅读起来比较方便的,第二种的灵活性更高一些
一、只定义公共路径
1. 创建一个js文件(以api.js为例)
```
const LoginURL = 'http://xxybi/login'
export default{
LoginURL,
}
```
2. 然后到main.js去挂载
```
import api from '@/api.js'
Vue . prototype . api= api
```
3. 使用
```
this.api.LoginURL
```
二、公共路径和请求地址分别定义,然后拼接,这样以后接口改动只要修改一个地方即可

2. 同上,到main.js去挂载
3. 使用
```
this.global.INTERFACES.homeSlideshow
```
网友评论