04. 零基础小白直接上手FastAPI+Vue3前后端分离开发

38 字约 1 分钟读完308 次阅读更新于 2026/5/3

vue 安装 axios 插件

 npm i axios -S

跨域配置

server: {
  proxy: {
    '/api': {
      target: 'http://127.0.0.1:9090',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
    }
  }
},

// 请求方式:
const ip = "/api"

axios.get(ip + '/student/selectPage')

新增数据

Dialog 弹窗

<el-dialog v-model="dialogVisible" title="学生信息" width="800">
      <el-form :model="form">
        <el-form-item label="Promotion name" :label-width="formLabelWidth">
          <el-input v-model="form.name" autocomplete="off" />
        </el-form-item>
      </el-form>

      <template #footer>
          <div class="dialog-footer">
            <el-button @click="dialogVisible = false">取消</el-button>
            <el-button type="primary" @click="save">保存</el-button>
          </div>
        </template>
    </el-dialog>

本节课完整的页面代码