sadek sadek - 3 years ago 164
Javascript Question

How can I call a method from html attribute in vue js

I have a form and I need to call a method from a placeholder and also from other types of html attribute.

Is there anyways I can call a vue method?
Here is what I am trying to do

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

It seems this method cannot be called this way. Is there any other ways to achieve this?

And my method is

methods: {
var local='fr';
return this.trans(key,local);

Answer Source

Use v-bind (

<input type="text" class="form-control" v-model="user.userName" 
 v-bind:placeholder="t('un')" required>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download