vue.js使用变量值作为函数上的表单模型名称来操纵输入字段
我有一个具有VUE模型的组件,我想从安装下的组件初始化函数中设置值。在变量中,我在安装函数下具有一定的价值。我在该变量中有模型名称。现在,如何访问该特定模型?仅供参考,所需的表单模型名称在变量内。
<template>
<a class='btn btn-sm btn-success' @click.prevent="openModule('sort__abc','asc')"><i class="fa fa-home" ></i> </a>
<select v-model="searchform['sort__abc']" class='btn-default' style='zoom:80%;' :name='"sort__abc"'>
<option value=''>Sort</option>
<option value='asc'>Asc</option>
<option value='desc'>Desc</option>
</select>
</template>
<script>
// Declare /user-management component
var cpage = 1;
export default {
name: 'user-management',
// Declare users (as object), form (as /vform instance) and /isFormCreateUserMode (as boolean
// defaulted to 'true') inside /data() { return {} }.
data() {
return {
//variables here
searchform: new Form()
}
},
methods: {
openModule(formModel, formData) {
//Now, I have model name on formModel and data on formData, how can i set the input value from here?
}
}
}
</script>
I have a component with vue model , I want to set value from the component initialization function under mounted. I have some value over under mounted function in a variable. and I have the model name inside that variable. Now, how can I access that particular model? FYI the required form model name is inside the variable.
<template>
<a class='btn btn-sm btn-success' @click.prevent="openModule('sort__abc','asc')"><i class="fa fa-home" ></i> </a>
<select v-model="searchform['sort__abc']" class='btn-default' style='zoom:80%;' :name='"sort__abc"'>
<option value=''>Sort</option>
<option value='asc'>Asc</option>
<option value='desc'>Desc</option>
</select>
</template>
<script>
// Declare /user-management component
var cpage = 1;
export default {
name: 'user-management',
// Declare users (as object), form (as /vform instance) and /isFormCreateUserMode (as boolean
// defaulted to 'true') inside /data() { return {} }.
data() {
return {
//variables here
searchform: new Form()
}
},
methods: {
openModule(formModel, formData) {
//Now, I have model name on formModel and data on formData, how can i set the input value from here?
}
}
}
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了解决方案。这是我的解决方案
I have found a solution. Here is my solution