账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    vue为什么使用了es5严格模式下不支持的with语句
    43
    0

    源码中的两个函数

       function generate(
            ast,
            options
        ) {
            var state = new CodegenState(options);
            var code = ast ? genElement(ast, state) : '_c("div")';
            return {
                render: ("with(this){return " + code + "}"),
                staticRenderFns: state.staticRenderFns
            }
        }
    function genStatic(el, state) {
        el.staticProcessed = true;
        state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
        return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
    }

    在vm.$options.render中

    function() {
        with(this){return _c("div")}
    }

    Vue.prototype._c, 仅仅是为了省略this吗,with不是存在性能问题么,而且严格模式也不支持。

    1
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    网站公告
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部