[Vue warn]: You are using the runtime-only build of Vue 牵扯到Vue runtime-compiler与runtime-only区别

[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.

1. Vue的编译渲染过程

template --> ast --> render函数 --> VDom --> 真实DOM

  • 先将template解析(parse)成抽象语法树(ast)
  • 将ast编译(compiler)成render函数
  • 将render函数渲染(render)成虚拟DOM
  • 最后将虚拟DOM渲染成真实DOM

(1) runtime-compiler的步骤
template --> ast --> render函数 --> VDom --> 真实DOM

(2) runtime-only的步骤
render函数 --> VDom --> 真实DOM

vue中两者的切换

/* 带webpack显性配置的 */
//webpack.config.js
//其实就是取别名,找到以 vue 结尾的,就去node_modules重新查一下路径
module.exports = {
  resolve: {
   alias: {
    'vue$': 'vue/dist/vue.esm.js' // 用 webpack 1 时需用 'vue/dist/vue.common.js'
  }
 }
}


/* webpack隐性配置的 */
//vue.config.js
//true 就是完整版的(即runtime-compiler)
module.exports = {
  runtimeCompiler: true  //ture: runtime-compiler  false: runtime-only
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yusirxiaer

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值