再学vue

157 阅读1分钟

已经差不多接近两年的时间没有接触vue了, 说起来已经有一段时间了, 在次使用起来发现已经对Vue很陌生了, 于是开始了新的学习

vue完整版 和运行时 对比

  • 特点 : vue 完整版有 compiler, 而 运行时 => 非完整版 是没有 compiler 的, 完整版的 vue 去除掉 compile 体积会缩小接近 40%
  • 试图层面: 完整版 卸载 html 或者 template 模板中,image.png, 完整版 vue 中的 h 其实就是鱿鱼须 写好传给render 的方法
  • 引入方法: 完整版 直接引入Vue.js, webpack 引入 需要配置 @alias, 使用@vue/slic 需要额外配置 , 运行时 引入vue.runtime.js, 默认使用运行时

templaterender 怎么用

  • template 使用方法
<div id="app">
    <!--此处的template标签中的内容显示并且在dom中不存在template标签-->
    <template>
        <div>我是template</div>
        <div>我是template</div>
    </template>
</div>
<!--此处的template标签中的内容在页面中不显示,但是在dom结构存在该标签及内部结构-->
<template id="tem">
    <div id="div1">我是template</div>
    <div>我是template</div>
</template>
<script src="node_modules/vue/dist/vue.js"></script>
<script>
    let vm = new Vue({
        el: "#app",
    });
</script>

  • render
import AnchoredHeading from './AnchoredHeading.vue'

new Vue({
  el: '#demo',
  render: function (h) {
    return (
      <AnchoredHeading level={1}>
        <span>Hello</span> world!
      </AnchoredHeading>
    )
  }
})

如何用 codesandbox.io 写 Vue 代码

image.png

  • 二、点击创建 Vue 项目

image.png

三、存储到本地完成 Vue 相关操作后,点击 File 下的 Export to ZIP ,可以导出 zip 压缩包到本地

image.png