关于vue

vue开发模式与生产模式

2019-06-01  本文已影响0人  简小园

在src文件夹下新建config.js文件

let server='';

if(process.env.NODE_ENV=='development'){
  server='http://localhost:8080/';
}else{
  server='http://00.00.00.00:00/';
}

export const SERVER=server;
config.js

需要前后端数据交互时,在文件js中引入。一定要加{}
import {SERVER} from '@/config';

async created(){
    let res=await fetch(SERVER+'api/account');
    let arr=await res.json();
    this.accounts=arr;
}
上一篇 下一篇

猜你喜欢

热点阅读