Javascript 如何从vue js中的html属性调用方法

Javascript 如何从vue js中的html属性调用方法,javascript,vue.js,vuejs2,Javascript,Vue.js,Vuejs2,我有一个表单,需要从占位符和其他类型的html属性调用一个方法 有什么方法可以调用vue方法吗? 这就是我要做的 <input type="text" class="form-control" v-model="user.userName" placeholder=t("un") required> // want to call method t() from the placeholder 使用v-bind() 从占位符调用方法是什么意思?也许你想要计算属性?嗨,谢谢你

我有一个表单,需要从占位符和其他类型的html属性调用一个方法

有什么方法可以调用vue方法吗? 这就是我要做的

<input type="text" class="form-control" v-model="user.userName" 
 placeholder=t("un") required> // want to call method t() from the placeholder
使用
v-bind
()




从占位符调用方法是什么意思?也许你想要计算属性?嗨,谢谢你的回复。这不是一个事件。我正试图调用一个方法
t()
,它是在我的
方法中声明的,来自
占位符
属性我已经编辑了这个问题。你想翻译你的占位符吗?是的,翻译逻辑是在t()方法中定义的。太好了,除了
单引号:)@sadek啊,是的。如果不转义它们,就不能在
内部嵌套
。另一种方法是使用
methods: {
   t(key){
        console.log(key)
        var local='fr';
        return this.trans(key,local);
      }
}
<input type="text" class="form-control" v-model="user.userName" 
 v-bind:placeholder="t('un')" required>
<input type="text" class="form-control" v-model="user.userName" :placeholder="t('un')" required>