浅析Vue版本分别

173 阅读1分钟

Vue有两个版本,一个是完整版,一个是非完整版

  • 完整版文件名 vue.js
  • 非完整版文件名 vue.runtime.js
  • 最终生产环境在.js前加.min

两个版本渲染视图的差别

  • 完整版可直接在html或template构造选项中编写
<template>
    {{'11'}}
</template>

new Vue({
    el:#app,
    template:`
    <div>hi</div>
    `
})
  • 非完整版需要写在render函数中
new Vue({
    el:#app,
    render(h){ //h是vue传递的,名字可替换成其他,类似于createElement的作用
        return h('div','test')
        //return h('组件名')也可以传入一个组件
    }
}).$mount('#app')

建议始终使用非完整版,配合vue-loader使用