wffranco / vue-strap

Bootstrap components built with Vue.js
http://wffranco.github.io/vue-strap/
MIT License
338 stars 133 forks source link

Initial values in inputs #150

Open dbarrington opened 7 years ago

dbarrington commented 7 years ago

Hi, just getting into this. I have read the docs, but I'm having trouble getting initial values into the inputs. I was expecting the initial value would be the value assigned to whatever I put in v-model (activityName in this case), but the input is starting empty, like the Input.vue file is not passing the v-model into the input.

Pretty sure it's me, but what am I don't wrong?

<template>
<bsInput label="Activity Name" type="text" required v-model="activityName"></bsInput>
</template>

<script>  
var bsInput = require('vue-strap/src/Input');

data: () => ({
activityName: 'wave'
}),

components: {
bsInput
}
</script>
dbarrington commented 7 years ago

Just to extend the question a little:

<div class="form-group">
    <label for="some-other-activity">Activity Name [non VueStrap]</label>
    <input type="text" name="some-other-activity" class="form-control" v-model="activityName">
  </div>

  <bsInput label="Activity Name [VueStrap]" type="text" required v-model="activityName"></bsInput>
screen shot 2017-08-27 at 9 15 46 am
Turaylon commented 7 years ago

I think there is a bug somewhere becouse on my project the input component does not show the value after some npm update. This is my vue inspection and as you can see the value passed correctly image

The code i used is simply this: <bs-input v-model="registration_number" placeholder="Matricola"></bs-input>

xpuu commented 6 years ago

I think there's something wrong between dynamic components and v-model.

<textarea :is="type=='textarea'?type:'input'"

Despite of being elegant, this part fucks it up somehow. It's even impossible to set simple :value="val" with type="textarea" etc.

bezborodow commented 6 years ago

@xpuu, I did my own testing and removed the <textarea :is="type=='textarea'?type:'input'" and replaced it with <input>. It seemed to work fine after that. This seems to confirm your assertion in this regard. I might do a pull request to implement a fix to avoid using :is. It might be worth reporting this apparent bug upstream to Vue, also.