Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

v-for 数组 中用字符串给v-model传绑定变量

我希望用 loginDialogForm 中的model字符串传给v-model,让他绑定字符串中的变量, 如何做到?
谢谢!!!

`

<el-form :model="loginDialogData" :ref="loginDialogData" label-width="80px" label-position="left">
              <el-form-item
                v-for="item in loginDialogFrom[loginDialogData.type]"
                :key="item.label"
                :label="item.label"
              >
                <el-input v-model="!###########!" :type=item.type ></el-input>
              </el-form-item>
            </el-form>
      loginDialogData: {
        type: 0,
        email: '',
        username: '',
        password: ''
      },
      loginDialogFrom: [
        [
          {label: '邮箱', model: 'loginDialogData.email', type: 'email'},
          {label: '密码', model: 'loginDialogData.password', type: 'password'}
        ],
        [
          {label: '邮箱', model: 'loginDialogData.email', type: 'email'},
          {label: '昵称', model: 'loginDialogData.username', type: ''},
          {label: '密码', model: 'loginDialogData.password', type: 'password'},
          {label: '确认密码', model: '', type: 'password'}
        ]
      ]

`


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
<el-input :type="item.type"  v-model="loginDialogData[item.model.split('.')[1]]"></el-input>

替换即可


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...