我有一个通过v-for生成的表单.
注意:我正在使用"@"来逃避刀片.
我的vue isstance有:
data: {
form: {
inputs: [{icon: "", name="", placeholder: "", type="", value=""}]
},
owner: {first_name: "", last_name: "", cell_phone: "", email: ""}
}
Run Code Online (Sandbox Code Playgroud)
我生成表格:
<template v-for="input in form.inputs">
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-@{{input.icon}}"></i></span>
<input id="login-@{{input.name}}" v-model="?????" type="@{{input.type}}" class="form-control" name="@{{input.name}}" placeholder="@{{input.placeholder}}">
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
我想将每个输入绑定到各自的承包商属性.所以我希望v-models值为owner.first_name,owner.last_name,owner.cell_phone和owner.电子邮件.我希望我能做到:
v-model="'owner' + @{{input.name}}"
Run Code Online (Sandbox Code Playgroud)
但我得到:
[Vue warn]: v-model="'owner' + {{input.name}}": attribute interpolation is not allowed in Vue.js directives and special attributes.
vue.js:1956 Error: Warning Stack Trace
at warn (vue.js:1956)
at Directive.bind (vue.js:4507)
at Directive._bind (vue.js:8668)
at linkAndCapture (vue.js:7367)
at compositeLinkFn (vue.js:7345)
at new Fragment (vue.js:5373)
at FragmentFactory.create (vue.js:5575)
at Directive.create (vue.js:5844)
at Directive.diff (vue.js:5757)
at Directive.update (vue.js:5692)
Run Code Online (Sandbox Code Playgroud)
所有者属性对应于每个输入的input.name.
谢谢
应用程序说明:我正在尝试使用多个表单来构建所有者.每个表单都是通过ajax请求生成的,该请求获取一个表单对象,该表单对象包含输入n和该表单的操作.
| 归档时间: |
|
| 查看次数: |
9875 次 |
| 最近记录: |