# Vue 2

# 脚手架

yarn global add @vue/cli # 安装
vue create 项目名称 # 创建项目

# 生命周期函数

created: function(){},
mounted : function(){},
beforeDestroy: function(){},
destroyed: function(){}

# Slot

<template>
  <!-- 子组件传递值给父组件 -->
  <slot a="1" b="msg"></slot>
  <slot name="foot"></slot>
</template>
<Comp scope="data">
  <div>{{data}}: {a: 1, b: 'msg'}</div> 
  <template #foot><div>foot content</div></template>
</Comp>

# 输出 HTML

<div v-html="raw_html"></div>

# 事件

# 阻止事件冒泡

<button @事件名.stop="doSth">点击</button>

# 组织默认行为

<button @事件名.prevent="doSth">点击</button>

# 给组件绑定原生事件

<MyComp @事件名.native="doSth">

# 避免闪烁

<div v-cloak>
  {{ message }}
</div>

# 文档