浅析Vue的完整版和只包含运行时版

157 阅读1分钟

一、两个版本的区别和对应的文件名

两个版本的区别:

  • 完整版是同时包含编译器和运行时的版本,文件名是vue.js
  • 只包含运行时版即是完整版除去编译器的其它一切,文件名是vue.runtime.js

二、template render用法

1 . vue完整版template的用法:直接写在htmlJS上:

<template>
    <div id="app">      
        {{n}}
        <button @click="add">+1</button>   
   </div> 
</template>

2 . vue只包含运行时版render的用法:render函数接收一个参数h,这个参数是vue传的;用这个参数去创建实例:

render(h){ 
     return h('div', [this.n,h('{on:{click:this.add}’,'+1'])
 }

三、使用codesandbox.io Vue 代码

1. 进入首页后,点击create sandbox

2. 点击Vue

3. 创建成功,代码敲起来~~