반응형
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
반응형
'programing' 카테고리의 다른 글
메모리 누수는 괜찮은가? (0) | 2022.05.11 |
---|---|
스틴트를 사용해야 하는 이유(또는 사용하지 않는 이유) (0) | 2022.05.11 |
Axios/Vuex api 쿼리가 작동하지 않음, 매개 변수 오류 (0) | 2022.05.11 |
Vue.js 문 닫는 동안 차단되지 않음(진행이 완료될 때까지 백엔드 대기) (0) | 2022.05.11 |
반올림 정수 분할(잘리는 대신) (0) | 2022.05.11 |