ソースを参照

fix(elevator): click highLight error(#1151)

suzigang 3 年 前
コミット
6395d0731d

+ 6 - 2
src/packages/__VUE/elevator/index.taro.vue

@@ -16,7 +16,9 @@
         <view class="nut-elevator__list__item__code">{{ item[acceptKey] }}</view>
         <view
           class="nut-elevator__list__item__name"
-          :class="{ 'nut-elevator__list__item__name--highcolor': currentData.id === subitem.id }"
+          :class="{
+            'nut-elevator__list__item__name--highcolor': currentData.id === subitem.id && currentKey === item[acceptKey]
+          }"
           v-for="subitem in item.list"
           :key="subitem['id']"
           @click="handleClickItem(item[acceptKey], subitem)"
@@ -85,7 +87,8 @@ export default create({
       currentIndex: 0,
       query: Taro.createSelectorQuery(),
       scrollTop: 0,
-      currentData: {} as ElevatorData
+      currentData: {} as ElevatorData,
+      currentKey: ''
     });
 
     const classes = computed(() => {
@@ -171,6 +174,7 @@ export default create({
     const handleClickItem = (key: string, item: ElevatorData) => {
       context.emit('click-item', key, item);
       state.currentData = item;
+      state.currentKey = key;
     };
 
     const handleClickIndex = (key: string) => {

+ 6 - 2
src/packages/__VUE/elevator/index.vue

@@ -5,7 +5,9 @@
         <view class="nut-elevator__list__item__code">{{ item[acceptKey] }}</view>
         <view
           class="nut-elevator__list__item__name"
-          :class="{ 'nut-elevator__list__item__name--highcolor': currentData.id === subitem.id }"
+          :class="{
+            'nut-elevator__list__item__name--highcolor': currentData.id === subitem.id && currentKey === item[acceptKey]
+          }"
           v-for="subitem in item.list"
           :key="subitem['id']"
           @click="handleClickItem(item[acceptKey], subitem)"
@@ -71,7 +73,8 @@ export default create({
       },
       scrollStart: false,
       currentIndex: 0,
-      currentData: {} as ElevatorData
+      currentData: {} as ElevatorData,
+      currentKey: ''
     });
 
     const classes = computed(() => {
@@ -152,6 +155,7 @@ export default create({
     const handleClickItem = (key: string, item: ElevatorData) => {
       context.emit('click-item', key, item);
       state.currentData = item;
+      state.currentKey = key;
     };
 
     const handleClickIndex = (key: string) => {