# 1 创建项目(找到目标目录创建项目D:\Virtualenvs)
vue create luffy_front
# 2 使用pycharm打开,配置可以使用点击启动
#配置npm run server
# 3 删除App.vue中的代码
"app">
# 4 删除 Helloworld.vue 和About.vue
# 5 修改 router--index.js,删掉 About的路径
# 6 配置全局css--》assets--》css--》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; /* 合并边框 */
}
# 7 在main.js中引入
// 引入写的全局css global.css
import './assets/css/global.css'
# 8 安装axios
npm install axios
# 9 在main.js中引入
import axios from "axios";
// 原型,把axios放到Vue的原型中
// 以后在vue对象中直接通过 this.$axios 拿到的就是axios
Vue.prototype.$axios=axios
# 10 编写配置文件 assets---》js---》settings.js
export default {
base_url:'http://127.0.0.1:8000' // 后端地址
}
# 11 在main.js中配置
import settings from "./assets/js/settings";
Vue.prototype.$settings=settings
# 12 以后在组件中使用
created() {
this.$axios.get(this.$settings.base_url + '/home/test2').then(res => {
console.log(res.data)
})
}