我可以通过pickerDate vuetify传递参数吗? [英] Can I pass a parameter by pickerDate vuetify?

查看:162
本文介绍了我可以通过pickerDate vuetify传递参数吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的日期选择器是这样的:

My datepicker like this :

<v-date-picker v-model="date" scrollable :picker-date.sync="pickerDate">

循环中的日期选择器

我的脚本像这样:

  data: () => ({
    date: new Date().toISOString().substr(0, 10),
    pickerDate: null,
  }),
  watch: {
    pickerDate (val) {
      console.log(val) 
    },
  },

在每个循环中,都有一个参数id,我想传递参数id

In every loop, there exist a parameter id and I want to pass parameter id

我尝试这样:

<v-date-picker v-model="date" scrollable :picker-date.sync="pickerDate(id)">

但是存在错误:

Syntax Error: SyntaxError: Unexpected token

如何解决此问题?

参考: https://vuetifyjs.com/en/components/date-pickers#date-pickers-react-to-displayed-month-year-change

推荐答案

您不能在picker-date中传递参数,但是仍然可以在Vuetify datepicker中传递更新:picker-date 事件
在datepicker中更改月份时,如果已选择,则返回值为2019-10一个月是十月。如果您将月份更改为11月,则值将为2019-11,并且id是您在迭代中传递的值

You cannot pass parameters in picker-date, but still you can pass in Vuetify datepicker update:picker-date event When you change the month in datepicker, it returns the value as 2019-10 if the selected month is October. If you change the month November then the value will be 2019-11 and id is what your passing on the iteration

      <v-date-picker
        v-model="date"
        class="mt-4"
        @update:picker-date="pickerUpdate($event, id)"
      ></v-date-picker>


new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  data: () => ({
    date: '2019-10-15',
    id: 5,
  }),
  methods: {
    pickerUpdate(val, id) {
      // you can read the val --> 2019-10 for october, id what you  are passing
      // when you iterate with multiple date picker, you can set id's 
      // write your async call here
       console.log('from picker update ' + val + '  id: ' + id );
    },
  },
})

这篇关于我可以通过pickerDate vuetify传递参数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆