vue implements the method of using v-for and v-if together

We generally know that v-if and v-for cannot be used together due to priority issues, but sometimes there is a need for such scenarios and we do not want to change the page layout.
So the solution I think is. Outside the components using v-for, wrap another layer of template tags. Then use v-if above, because the template is just a wrapping element, it will not perform any rendering on the page. Therefore, v-if and v-for can also be used together.
like:

  <template v-if="false">
                <el-option v-for="item in projectStatus" :value="item.label">
                </el-option>
              </template>

Guess you like

Origin blog.csdn.net/weixin_45807026/article/details/126574449