前端配置
1 axios
- 安装
cnpm install axios -S
main.js
中
import axios from 'axios'
Vue.prototype.$axios=axios
2 elementui
- 安装
cnpm install element-ui -S
main.js
中
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);
3 cookies
- 安装
cnpm install vue-cookies -S
main.js
中
import cookies from 'vue-cookies'
Vue.prototype.$cookies = cookies;
4 写个settings.js
const BASE_URL='http://127.0.0.1:8000/api/v1/'
export default {
banner:BASE_URL+'/home/banner/',
}
main.js
中
import settings from "@/assets/js/settings";
Vue.prototype.$settings=settings
-
再组件中使用
methods:{
getdata(){
async function a(){
let response=await this.$axios(this.$settings.banner)methods:{ getdata(){ async function a(){ let response=await this.$axios(this.$settings.banner } } }
5 去掉默认样式
global.css
声明全局样式和项目的初始化样式
body, h1, h2, h3, h4, h5, h6, p, table, tr, td, ul, li, a, form, input, select, option, textarea {
margin: 0;
padding: 0;
font-size: 15px;
}
a {
text-decoration: none;
color: #333;
}
ul {
list-style: none;
}
table {
border-collapse: collapse; /* 合并边框 */
}
main.js
中 全局css
import '@/assets/css/global.css'
标签:cookies,axios,settings,前端,配置,js,vue,import,main
From: https://www.cnblogs.com/unrealqcc/p/18194585