javascript - add placeholder dynamically vuejs - Stack Overflow

this is a part of my code.<input type="text" v-model="formData.end_date" name=&q

this is a part of my code.

    <input type="text" v-model="formData.end_date" name="end_date" v-validate="'required'"
           v-bind:class="{'input-error' : errors.has('end_date')}">
    <span v-show="errors.has('end_date')"
          style="position: absolute; font-size: .7em ; margin-right: 1em;color: rgb(214, 48, 49);">{{errors.first('end_date') }}</span>
</div>

how can I add placeholder dynamically when error.has('end_date') return true

I try v-bind: placeholder

this is a part of my code.

    <input type="text" v-model="formData.end_date" name="end_date" v-validate="'required'"
           v-bind:class="{'input-error' : errors.has('end_date')}">
    <span v-show="errors.has('end_date')"
          style="position: absolute; font-size: .7em ; margin-right: 1em;color: rgb(214, 48, 49);">{{errors.first('end_date') }}</span>
</div>

how can I add placeholder dynamically when error.has('end_date') return true

I try v-bind: placeholder

Share Improve this question asked Sep 20, 2018 at 13:48 movAhedmovAhed 731 gold badge2 silver badges15 bronze badges 1
  • You can also use <input :placeholder="[[ urlPlaceholder ]]"> – Carca Commented Feb 21, 2020 at 13:35
Add a ment  | 

3 Answers 3

Reset to default 4

Try something like this:

1) Add a puted property to your ponent

puted: {
   placeholder() {
      return this.errors.has('end_date') ? 'Your placeholder text' : ''
   }
}

2) Bind to your puted placeholder property with v-bind:placeholder="placeholder"

you can get that done by saying :placeholder. Is that not working for you ? In your try you have a space between v-bind:placeholder. I think you should not be having that.

<input
   type="text"
   v-model="FirstName"
   class="form-control"
   :placeholder="functionData"
/>

puted:{
   functionData(){
     return "Data"
  }
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745234467a4617825.html

相关推荐

  • javascript - add placeholder dynamically vuejs - Stack Overflow

    this is a part of my code.<input type="text" v-model="formData.end_date" name=&q

    20小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信