Welcome to OStack Knowledge Sharing 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 Answer

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

替换即可


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...