首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >vuetify v-select laravel

vuetify v-select laravel
EN

Stack Overflow用户
提问于 2020-05-02 01:44:45
回答 1查看 152关注 0票数 0

我们有一个来自laravel后端的数据表。我们需要每月对数据进行排序。在Laravel网站上,我们有:

代码语言:javascript
复制
$per_page = $request->per_page;//? $request->per_page : 10;
$sortBy = $request->sort_by;
$orderBy = $request->order_by;
$month = $request->month;
return response()->json(['o2attendances' => O2attendance::whereMonth('date' , $month)->whereYear('date' , Carbon::today()->year)->orderBy($sortBy, $orderBy)->paginate($per_page)], 200);

在Vuejs上,我们有:

代码语言:javascript
复制
<v-select
            :items="mesiace"
            item-text="text"
            item-value="value"
            hide-details
            height="20"
            @change="sortValue"
            filter
></v-select>
mesiace: [
      { text: "januar", value: "01" },
      { text: "februar", value: "02" },
      { text: "marec", value: "03" },
      { text: "april", value: "04" },
      { text: "maj", value: "05" },
      { text: "jun", value: "06" },
      { text: "jul", value: "07" },
      { text: "august", value: "08" },
      { text: "september", value: "09" },
      { text: "oktober", value: "10" },
      { text: "november", value: "11" },
      { text: "december", value: "12" }
    ],
methods:
    sortValue() {
      const sortBy =
        this.options.sortBy.length == 0 ? "date" : this.options.sortBy[0];
      const orderBy =
        this.options.sortDesc.length > 0 && this.options.sortDesc[0]
          ? "asc"
          : "desc";
      axios
        .get(`https://api/api/v1/o2attendances/all`, {
          params: {
            sort_by: sortBy,
            order_by: orderBy,
            month: this.mesiace.value
          }
        })
        .then(response => {
          this.o2attendances = response.data.o2attendances;
        });
    },

当我们在sortValue月份中更改:"04“或"05”时,它可以工作,但this.mesiace.value它不工作。

EN

回答 1

Stack Overflow用户

发布于 2020-05-02 04:05:37

这是有效的:

代码语言:javascript
复制
 <v-select
        :items="mesiace"
        v-model="mesiac"
        item-text="text"
        item-value="value"
        hide-details
        height="20"
        @change="sortValue"
        filter
      ></v-select>

添加了v-model

代码语言:javascript
复制
mesiac: null,

代码语言:javascript
复制
methods:
sortValue() {
  const sortBy =
    this.options.sortBy.length == 0 ? "date" : this.options.sortBy[0];
  const orderBy =
    this.options.sortDesc.length > 0 && this.options.sortDesc[0]
      ? "asc"
      : "desc";
  axios
    .get(`https://api/api/v1/o2attendances/all`, {
      params: {
        sort_by: sortBy,
        order_by: orderBy,
        month: this.mesiac
      }
    })
    .then(response => {
      this.o2attendances = response.data.o2attendances;
    });
},
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61547765

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档