I've encountered an issue while using v-model
on an input box. I'm trying to bind the value as a number, but it doesn't seem to be working as expected. When I perform an operation like myModel += 25
, instead of getting 125
, I end up with 10025
, indicating that the value is being saved as a string.
Is there a way to ensure that the input binds as a number?
Here's what my input element code looks like:
<input type="text" list="zoom-amount" v-model="project.zoom" />
<datalist id="zoom-amount">
<option>25</option>
<option>50</option>
<option>100</option>
<option>150</option>
<option>200</option>
</datalist>
@Component
export default class WorkspaceStatusBar extends Vue {
@Provide() public project: Project = this.activeProject
public get activeProject() {
return this.$store.getters['project/getActiveProject']
}
@Watch('activeProject')
public onActiveProjectChanged(newProject: Project) {
this.project = newProject
}
}