我想访问输入的引用,但仍然不确定。
//模板中的样本 模板:
<input type="text" class="form-control form-control-sm" v-bind:value=meminfo.last_name name="online_membership[last_name]" ref="online_membership[last_name]" >
脚本:
methods() {
function() {
// i would like to access the input value of this ref
this.$refs.online_membership[last_name]
}
}
答案 0 :(得分:0)
您应该更改以下内容:
最佳做法:
//模板模板中的示例:
<input type="text" class="form-control form-control-sm" v-bind:value=meminfo.last_name name="online_membership[last_name]" :ref="online_membership[last_name]" >
脚本:
methods() {
function() {
// i would like to access the input value of this ref
this.$refs[online_membership[last_name]]
}
}
但是仍然,如果您想用作包含'['的字符串,则只需使用以下解决方案即可:
//模板模板中的示例:
<input type="text" class="form-control form-control-sm" v-bind:value=meminfo.last_name name="online_membership[last_name]" ref="'online_membership[last_name]'" >
脚本:
methods() {
function() {
// i would like to access the input value of this ref
this.$refs['online_membership[last_name]']
}
}
希望它将解决您的问题