javascript - How can we set a default value of a v-text-field of vuetify in nuxtjs? - Stack Overflow

I am new to vuejs and nuxtjs and at my pany they are using vuetify. I need to set default value as 0 to

I am new to vuejs and nuxtjs and at my pany they are using vuetify. I need to set default value as 0 to v-text-field fields in the application but I cant find the to do so in the vuetify doc.

I am new to vuejs and nuxtjs and at my pany they are using vuetify. I need to set default value as 0 to v-text-field fields in the application but I cant find the to do so in the vuetify doc.

Share Improve this question asked May 12, 2022 at 21:43 Maninder KaurManinder Kaur 312 silver badges5 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

You can provide the default value 0 on the actual property bound to v-model from data object itself. <v-text-field> is just a wrapper around an html <input>. Hence, it will bind the data in same way how we are binding for input.

Demo :

new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  data: () => ({
    textFieldValue: 0,
  })
})
<link href="https://cdn.jsdelivr/npm/[email protected]/dist/vuetify.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr/npm/[email protected]/dist/vue.js"></script>
<script src="https://cdn.jsdelivr/npm/[email protected]/dist/vuetify.js"></script>

<div id="app">
    <v-text-field v-model="textFieldValue"/>
  </div>
</div>

You can use the v-model directive and just set the default value to 0 in your data property. Example: <v-text-field v-model="textField" label="My Text Field/> and in your data: data: () => ({ textField: 0, })

Hope it's the right answer, cheers

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

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

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

关注微信