GET http:// localhost:8080 / customer / src / components / manufacturer_conn.php 404(未找到)

时间:2019-10-08 04:13:33

标签: php vue.js axios

我是vue.js的新手,正在尝试将vue.js连接到我的数据库。

我想创建一个网站,以查看我的数据库中的所有制造商。

我做了一些研究,发现可以使用axios来获取文件,但是我传递的路径不起作用。

这是我的文件夹:

  customer
     src
       components
           hello_world.vue
        sql
           manufacturer_conn.php
           connection.php

这是我的hello_world.vue

<template>
  <div class="hello">
   <div v-for="manufacturer in manufacturers"  v-bind:key="manufacturer">
     {{manufacturer}}
     {{text}}
   </div>
  </div>
</template>

<script>
const axios = require('axios');

export default {
  name: 'HelloWorld',
 data:function(){
   return{
    manufacturers: ['hi','hello','to','you'],
    text: 'hi-------',
   }
  },

  beforeCreate(){
     axios.get('customer/src/sql/manufacturer_conn.php')
      .then(function (response) {
         app.manufacturers = response.data;
      })
      .catch(function (error) {
         console.log(error);
      });
  },
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>

这是我的Manufacturer_conn.php代码:

<?php
 console.log('--hi--');
include 'config.php';

$manufacurer = mysqli_query($con,"select * from manufacurer");

$response = array();

while($row = mysqli_fetch_assoc($manufacurer)){

   $response[] = $row;
}

echo json_encode($response);
exit;

错误:

GET http://localhost:8080/customer/src/sql/manufacturer_conn.php 404 (Not Found)
Error: Request failed with status code 404
    at createError (createError.js?2d83:16)
    at settle (settle.js?467f:17)
    at XMLHttpRequest.handleLoad (xhr.js?b50d:59)

似乎我的道路不正确,无法弄清楚应该是什么。

0 个答案:

没有答案