Browse Source

跨域

chenzhen/feature-20251107115823-股票知识测评
chenzhen 2 months ago
parent
commit
ddd77ccefb
  1. 2
      src/views/HomeView.vue
  2. 49
      src/views/WrongQuestion.vue
  3. 30
      vue.config.js

2
src/views/HomeView.vue

@ -21,7 +21,7 @@ export default {
// jwcode:90098889,//
// jwcode:90098890,//
// jwcode:90098891,//
jwcode:90098892,//
jwcode:90098892,//
// jwcode:90098893,//
// jwcode:90098894,//
};

49
src/views/WrongQuestion.vue

@ -0,0 +1,49 @@
<!-- src/views/WrongQuestion.vue -->
<template>
<div class="wrong-question">
<!-- 搜索区域组件 -->
<WrongQuestionSearch
ref="wrongQuestionSearch"
@search="handleSearch"
/>
<!-- 错题表格组件 -->
<WrongQuestionTable
ref="wrongQuestionTable"
@view-user="viewUser"
@view-question="viewQuestion"
/>
</div>
</template>
<script>
import WrongQuestionSearch from '@/components/WrongQuestion/WrongQuestionSearch.vue'
import WrongQuestionTable from '@/components/WrongQuestion/WrongQuestionTable.vue'
export default {
name: 'WrongQuestion',
components: {
WrongQuestionSearch,
WrongQuestionTable
},
methods: {
handleSearch(filters) {
//
this.$refs.wrongQuestionTable.setData(data);
},
viewUser(item) {
console.log('查看出错用户:', item)
},
viewQuestion(item) {
console.log('查看题目:', item)
}
}
}
</script>
<style scoped>
.wrong-question {
padding: 20px;
}
</style>

30
vue.config.js

@ -1,4 +1,32 @@
// const { defineConfig } = require('@vue/cli-service')
// module.exports = defineConfig({
// transpileDependencies: true
// })
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true
devServer: {
proxy: {
// 代理所有以 /api 开头的请求
'/api': {
target: 'http://192.168.40.41:8000', // 你的后端地址
changeOrigin: true, // 允许跨域
pathRewrite: {
'^/api': '' // 重写路径,去掉 /api 前缀
},
secure: false, // 如果是https接口,需要配置这个参数
logLevel: 'debug' // 查看代理日志
},
// 可以配置多个代理
'/upload': {
target: 'http://localhost:3000',
changeOrigin: true
}
},
// 允许外部访问
host: '0.0.0.0',
port: 8080
}
})
Loading…
Cancel
Save