Skip to content

vuejs 禁用 v-if & v-show directives #68

@hawtim

Description

@hawtim

背景

最近在做项目重构,重构涉及组件库的迁移工作,主要涉及到的是样式的变更。
为了将现存页面的所有展示逻辑呈现出来,我需要将 vuejs 的 v-if v-show 等条件渲染指令禁用掉

目标实现

修改 vue.runtime.esm.js, 版本 v2.6.14

// Line 8142
var isVShowDirective = function (d) { return d.name === 'show'; };
// 修改为
var isVShowDirective = function (d) { return false };

修改 node_modules/vue-template-compiler/build.js

if (inVPre) {
    processRawAttrs(element);
  } else if (!element.processed) {
    // structural directives
    processFor(element);
    // 注释掉下面这行
    // processIf(element);
    processOnce(element);
  }

可以使所有的 vue 的条件渲染指令失效,使页面展示出所有的逻辑元素,方便调试

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions