我使用 codeigniter4 作为后端,使用 vue3 作为前端。在vue3中显示图像时出现此问题: 响应被 CORB(跨源读取阻止)阻止 跨源读取阻止 (CORB) 阻止了跨源响应。
请帮我解决这个问题。
这是我的代码:
(codeigniter)
public function show($id = null)
{
$model = new Product();
$data = $model->find($id);
if ($data) {
$data['product_photo'] = base_url('uploads/' . $data['product_photo']);
$data['supplier_names'] = $this->getSupplierNamesForProduct($id);
return $this->respond($data);
}
return $this->failNotFound('Product not found');
}
(vue)
<script>
import axios from 'axios';
export default {
name: 'ProductOverview',
data() {
return {
productId: this.$route.params.id,
product: {
product_photo: '',
// other product properties
}
};
},
mounted() {
this.getData();
},
methods: {
getData() {
axios.get(`http://localhost:8080/products/${this.productId}`)
.then(res => {
this.product = res.data;
})
.catch(error => {
console.error("There was an error fetching the product data:", error);
});
}
}
};
</script>
我希望 CORB 问题能够得到解决。