已经差不多接近两年的时间没有接触vue了, 说起来已经有一段时间了, 在次使用起来发现已经对Vue很陌生了, 于是开始了新的学习
vue完整版 和运行时 对比
- 特点 :
vue完整版有 compiler, 而 运行时 =>非完整版是没有compiler的, 完整版的vue去除掉compile体积会缩小接近 40% - 试图层面: 完整版 卸载
html或者template模板中,, 完整版
vue中的 h 其实就是鱿鱼须 写好传给render的方法 - 引入方法: 完整版 直接引入Vue.js,
webpack引入 需要配置 @alias, 使用@vue/slic需要额外配置 , 运行时 引入vue.runtime.js, 默认使用运行时
template和render怎么用
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 代码
-
一、打开 CodeSandBox.io
-
二、点击创建 Vue 项目
三、存储到本地完成
Vue相关操作后,点击File下的Export to ZIP,可以导出zip压缩包到本地