반응형
Vue - 래퍼 구성 요소의 프로펠을 재정의하는 방법
Quasar q-select를 다음과 같이 랩하는 래퍼 컴포넌트를 만들었습니다.
<template lang="pug">
q-select(
:options="organisations"
option-value="id"
v-bind="$attrs"
v-on="$listeners"
:option-label="item => item.details.name"
:label="$t('organisations.label')")
</template>
그리고 이름을 붙였다.OrganisationSelect
라벨에 디폴트값을 붙이고 싶다.i18n
이제 이걸 덮어쓸 수 있게 됐으면 좋겠어요.:label
이 컴포넌트를 사용하면 다음과 같이 됩니다.
div.col-4
OrganiastionSelect(
:rules="[val => !!val || 'Please select an Organisation']"
v-model='organisation'
:label="$t('organisation.someOtherLabel')"
dense
).col-6
이 라벨은 someOtherLabel이 사용되지 않습니다.항상 내부 라벨을 사용합니다.
질문:.
그런 제안이 우선시 되는 것이 가능한가?만약 그렇다면, 어떻게?
OrganisationSelect
를 제공할 수 있습니다.label
디폴트인 프로펠러$t('organisations.label')
, 그 소품을 에 바인드 합니다.<q-select>.label
:
<template lang="pug">
q-select(
...
:label="label"
)
</template>
<script>
export default {
props: {
label: {
type: String,
default() {
return this.$t('organisations.label')
}
}
}
}
</script>
언급URL : https://stackoverflow.com/questions/59790086/vue-how-to-override-a-prop-of-a-wrapper-component
반응형
'itsource' 카테고리의 다른 글
.o, .a 및 .so 파일의 차이점은 무엇입니까? (0) | 2022.08.21 |
---|---|
상수 변수는 C의 어디에 저장됩니까? (0) | 2022.08.21 |
Spring 3.0 - XML 스키마 네임스페이스용 Spring NamespaceHandler를 찾을 수 없습니다[ http://www.springframework.org/schema/security ] (0) | 2022.08.21 |
word2vec bin 파일을 텍스트로 변환 (0) | 2022.08.21 |
루트 메타데이터 키가 true로 설정된 경우 특정 경로에서 구성 요소를 모달로 렌더링합니다. (0) | 2022.08.21 |