GithubHelp home page GithubHelp logo

Comments (7)

alireza-ab avatar alireza-ab commented on May 26, 2024 1

Hi @mohammadfiroozi
the new version is published and I add the setDate method for your problem.

<date-picker v-model="date" mode="single" ref="dp"></date-picker>
export default {
  data() {
    return {
      date: null
    }
  },
  mounted(){
    this.$refs.dp.setDate("2021/5/12");
  }
}

I suggest setting the data model before the component is mounted. use this way, after the component is mounted.

from vue-persian-datepicker.

honarmanly avatar honarmanly commented on May 26, 2024 1

@honarmanly Yes. it's right. I fix it.

thanks

from vue-persian-datepicker.

alireza-ab avatar alireza-ab commented on May 26, 2024

Hi @mohammadfiroozi

In single mode use string and in range mode use array. (date must be gregorian)

<date-picker v-model="date" mode="single"></date-picker>
export default {
  data() {
    return {
      date: "2021/05/12"
    }
  }
}

<date-picker v-model="date" mode="range"></date-picker>
export default {
  data() {
    return {
      date: ["2021/05/12", "2021/05/15"]
    }
  }
}

from vue-persian-datepicker.

mohammadfiroozi avatar mohammadfiroozi commented on May 26, 2024

this not working when i set it in created life cycle or other method,

<date-picker v-model="formValues.birthDate" mode="single"></date-picker>

`
created() {

this.formValues= {
nationalCode: this.nationalCode,
birthDate: "2021/05/12"
};

}
`

from vue-persian-datepicker.

alireza-ab avatar alireza-ab commented on May 26, 2024

The data model must be filled before the component is mounted.
I suggest using beforeMount to set the data model.

If you can not set the data model before mount, use this way:

<date-picker v-model="date" mode="single" ref="dp"></date-picker>
import { PersianDate } from "@alireza-ab/vue-persian-datepicker"
export default {
  data() {
    return {
      date: null
    }
  },
  created(){
    this.$refs.dp.selectDate(new PersianDate("2021/5/12"), "date");
  }
}

In the next version, I add a better way to set the data model.

from vue-persian-datepicker.

honarmanly avatar honarmanly commented on May 26, 2024

$ref is not defined in created phase, but I used it in mounted and it works

from vue-persian-datepicker.

alireza-ab avatar alireza-ab commented on May 26, 2024

@honarmanly
Yes. it's right. I fix it.

from vue-persian-datepicker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.