1. 程式人生 > 其它 >el-radio-group 有值還渲染失敗

el-radio-group 有值還渲染失敗

問題

 

 

 

程式碼

     <div class="down-tree">
                  <el-tree
                    :data="menuData" @check-change="clickMenu"
                    show-checkbox  :props="props"
                    node-key="menuId" ref="tree"
                    :expand-on-click-node="false">
                    <
span class="custom-tree-node" slot-scope="{ node, data }"> <span style="font-size:12px;">{{ data.name }}</span> <span v-if="checkNodeType(data)"> <el-radio-group v-model="data.prmissionType"> <
el-radio label="1">本部門</el-radio> <el-radio label="2">本車間</el-radio> <el-radio label="3" @change="showMenuPermission(data)"><el-button type="text" size="mini" @click="showMenuPermission(data)">跨部門</el-button></
el-radio> <el-radio label="4">本使用者</el-radio> </el-radio-group> </span> </span> </el-tree> </div>

 

 

渲染值

    queryRoleMenuData(){
          const url = `/core/menuRolePrmission`;
          const name = "角色欄位許可權";
          this.query.tableName = this.tableName;
          this.axios.post(url, this.query)
            .then((res) => {
              this.menuData = res.data.responseBody["resultList"];
              console.log(2,typeof this.menuData)
              this.checkedMenuIds = res.data.responseBody["checkedMenuIds"];
              this.halfCheckedMenuIds = res.data.responseBody["halfCheckedMenuIds"];
              // this.$nextTick(function(){
                this.$refs.tree.setCheckedKeys(this.checkedMenuIds); //設定完全選中節點
              // this.$refs.tree.setHelfCheckedKeys(this.halfCheckedMenuIds); //設定半選中節點
              // });
            }
          );
        },

  原先一直在這兩個部分找原因,試了很多種方法也不行,後面請教了一下大哥,發現是在el-tree 裡面有一個改變選中節點的方法,把值給改變了

 

裡面的程式碼

 clickMenu(data,check,childrenCheck){
          if(check){
            data.prmissionType = "1";
          } else {
            data.prmissionType = null;
          }
        },

註釋掉就好了