반응형
Vuex에서 v-select의 기본값을 두 스토어에서 어떻게 선택합니까?
Vuex 스토어에서 채우는 v-select가 있습니다.v-select에서 계산된 속성(고객)에서 가져온 다른 개체의 속성 ID와 일치하는 값을 선택해야 하지만 이 값을 사용할 수 없습니다.
상태를 변경하고 싶지 않습니다. 고객 객체의 priceListId ID에 따라 일치하는 드롭다운 값을 표시하고 싶습니다.
V-선택:
<v-select :items="priceLists"
item-text="name"
item-value="id"
label="pricelist"
v-model="select"
select
return-object></v-select>
모델 코드:
export default {
data: () => ({
select: null
}),
computed: {
priceLists () {
return this.$store.state.pricelists.pricelists
},
customer () {
return this.$store.state.customers.customers.find(customer =>
customer.id === Number(this.customer.id))
}
}
아이디어 있어요?
감시자 사용customer
자동 설정select
(가격 리스트의 v-model)<v-select>
)에 의해 원하는 가격 리스트로.customer.priceListId
:
watch: {
customer: {
immediate: true,
handler(value) {
this.select = value.priceListId;
}
}
}
언급URL : https://stackoverflow.com/questions/53554011/how-do-you-select-a-default-value-in-v-select-from-vuex-from-two-stores
반응형
'sourcetip' 카테고리의 다른 글
데이터 유형을 문자열로 변경하는 방법은 무엇입니까? (0) | 2023.07.07 |
---|---|
저장소에 있지 않고 Git 명령을 실행하려면 어떻게 해야 합니까? (0) | 2023.07.07 |
ASP.NET에서 모든 브라우저에 대해 브라우저 캐싱 사용 안 함 (0) | 2023.07.07 |
mongo 데이터베이스 url에서 authSource는 무엇을 의미합니까? (0) | 2023.07.07 |
Python df.to _messages는 숫자를 excel의 텍스트로 저장할 수 없습니다.가치로 저장하는 방법? (0) | 2023.07.07 |