Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
DB::table(';table';)->;选择返回空字符串Laravel 6_Laravel_Vue.js - Fatal编程技术网

DB::table(';table';)->;选择返回空字符串Laravel 6

DB::table(';table';)->;选择返回空字符串Laravel 6,laravel,vue.js,Laravel,Vue.js,我正在将Laravel 6与Vue axios一起使用,我想用“fjl_组”表中的内容填充一个表单选择。但是每次我检查控制台的结果,它都会返回一个空字符串,你知道为什么吗?我的Laravel日志也没有返回任何错误,所以我不知道发生了什么 Vue的部分 <b-col cols="4"> <label for="editorial">Group</label> <b-form-select v-model="group" :options="

我正在将Laravel 6与Vue axios一起使用,我想用“fjl_组”表中的内容填充一个表单选择。但是每次我检查控制台的结果,它都会返回一个空字符串,你知道为什么吗?我的Laravel日志也没有返回任何错误,所以我不知道发生了什么

Vue的部分

<b-col cols="4">
    <label for="editorial">Group</label>
    <b-form-select v-model="group" :options="groups" id="groups" name="groups"></b-form-select>
</b-col>

<script>
export default {
    data() {
        return {
            group: null,
            groups: [{
                value: null,
                text: 'Select'
            }]
        }
    },

    created(){
        axios.get('/clubs/create')
            .then(res => {
                this.groups = res.data;
                console.log(this.groups);
            }).catch(e => {
                console.log(e);
            })
    },
    }
}
</script>

集团模式

class Group extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'fjl_groups';
    public $timestamps = false;
}

您没有返回值。您只是在执行选择

请尝试返回:

return response()->json([
  'data' => DB::table('fjl_groups')->select('id as value', 'nom as text')->get()
]);

我这样做了,它返回了一个奇怪的数组:
对象{readyState:Getter&Setter,getResponseHeader:Getter&Setter,GetAllResponseHeader:Getter&Setter,setRequestHeader:Getter&Setter,OverrideMetype:Getter&Setter,statusCode:Getter&Setter,abort:Getter&Setter,state:Getter&Setter,always:Getter&Setter,catch:Getter&Setter,}
return response()->json([
  'data' => DB::table('fjl_groups')->select('id as value', 'nom as text')->get()
]);