vue & template & v-else & v-for bug


vue & template & v-else & v-for bug

nested table bug

https://codepen.io/xgqfrms/pen/wvaGmGE

bug

      <el-table-column
        v-for="({
          prop,
          label,
          align,
          width,
          slot,
        }, i) in selectManageClomuns"
        :key="prop + i"
        :prop="prop"
        :width="width"
        :align="align"
        :label="label">
        <!-- rowSpan ??? -->
        <template
          v-if="tableData[scope.$index].render"
          slot-scope="scope">
          <span>
            {{tableData[scope.$index][prop]}}
          </span>
          <div v-if="prop === 'showName'">
            <el-button
              type="primary"
              size="small"
              @click="editHandler(scope.$index, scope.row)">
              關閉選排
            </el-button>
            <el-button
              type="primary"
              size="small"
              @click="editHandler(scope.$index, scope.row)">
              創建新模版
            </el-button>
          </div>
          <div v-else></div>
        </template>
        <template
          v-else
          slot-scope="scope">
          <span>
            {{tableData[scope.$index][prop]}}
          </span>
        </template>
      </el-table-column>

solution

not using v-else template in v-for, instead of using div as box


      <el-table-column
        v-for="({
          prop,
          label,
          align,
          width,
          slot,
        }, i) in selectManageClomuns"
        :key="prop + i"
        :prop="prop"
        :width="width"
        :align="align"
        :label="label">
        <!-- rowSpan ??? -->
        <template
          slot-scope="scope">
          <div v-if="tableData[scope.$index].render">
            <span>
              {{tableData[scope.$index][prop]}}
            </span>
            <div v-if="prop === 'showName'">
              <el-button
                type="primary"
                size="small"
                @click="editHandler(scope.$index, scope.row)">
                關閉選排
              </el-button>
              <el-button
                type="primary"
                size="small"
                @click="editHandler(scope.$index, scope.row)">
                創建新模版
              </el-button>
            </div>
          </div>
          <div v-else>
            <span v-if="prop !== 'showName'">
              {{tableData[scope.$index][prop]}}
            </span>
          </div>
        </template>
      </el-table-column>

refs



©xgqfrms 2012-2020

www.cnblogs.com 發布文章使用:只允許注冊用戶才可以訪問!

原創文章,版權所有©️xgqfrms, 禁止轉載 🈲️,侵權必究⚠️!



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM