JavaScript/vue.js/一个简单组件的调试过程:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
Kangkk​(留言 | 贡献)
第580行: 第580行:


留待后续更新。
留待后续更新。
这里涉及的是数据渲染的过程,
使用一种非主流的方法,尽量缩短数据渲染的时间
<syntaxhighlight lang="html5">
<template>
...
      <div class="left"
          :class="[$nav_category.title,{[$nav_category.disClick]:allPropsKey[index].status}]">
...
        <el-radio-group v-for="child in item.child"
...
                        :class="{[$nav_category.disClick]:isDisClick(item.enName, child.key)}"
...
</template>
<style module="$nav_category" lang="scss">@import "./category";</style>
<script>
...
    computed: {
      cloneAllPropsKeyIndex :{
        get (){
          return this.tmpIndexArr.slice()
        },
        set (index){
          this.tmpIndexArr[index]++
          if(this.allPropsKey[index].count <= this.tmpIndexArr[index]){
            const _that = this
            setTimeout(function (){
              _that.allPropsKey[index].status = true
            },0.01)
          }
        }
      },
    },
    watch:{
      allPropsKey:{
        handler (newVal, oldVal) {
        },
        deep: true
      }
    },
    ...
      isDisClick (itemEnName,childName){
        // 判断二级标签背景状态,以二级标签为锚点,如果只是二级标签中其中一个命中,一级标签不做改变,如果二级标签全部命中,一级标签背景改变
        const index = this.allPropsKey.findIndex(o=> o.name===itemEnName)
        const cb = this.disClickFilter({[itemEnName]:childName})
        if(cb && this.allPropsKey[index].status !== true){
          this.cloneAllPropsKeyIndex = index
...</syntaxhighlight>