programing

vue js의 html 속성에서 메서드를 호출하는 방법

prostudy 2022. 5. 11. 22:03
반응형

vue js의 html 속성에서 메서드를 호출하는 방법

나는 양식이 있고 자리 표시자 및 다른 종류의 html 속성에서 메서드를 호출해야 한다.

내가 부메서드를 부를 수 있는 방법이 없을까?여기 내가 하고자 하는 일이 있다.

<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-filename)

<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>

참조URL: https://stackoverflow.com/questions/46501392/how-can-i-call-a-method-from-html-attribute-in-vue-js

반응형