我有一个表单,我需要从占位符以及其他类型的html属性调用方法。
无论如何,我可以调用vue方法吗?这是我想做的
<input type="text" class="form-control" v-model="user.userName"
placeholder=t("un") required> // want to call method t() from the placeholder
似乎无法以这种方式调用此方法。还有其他方法可以做到这一点吗?
我的方法是
methods: {
t(key){
console.log(key)
var local='fr';
return this.trans(key,local);
}
}
使用v-bind
(https://vuejs.org/v2/api/#v-bind)
<input type="text" class="form-control" v-model="user.userName"
v-bind:placeholder="t('un')" required>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句