一步一脚印,踩坑给你看。
无限期记录一下自己踩过的坑,前人栽树后人乘凉。
假设有如下代码
<div>
i am parent
<child :prop1="prop1"></child>
<child2 :prop1="prop2"></child2>
</div>
并为各个父子组件的生命周期进行输出观察得到以下结论:
从上到下将会执行每个组件的beforeCreate->created->beforeMount(特地用—-来划分输出),随后将从里到外执行每个组件的mounted。
```console from chrome
parent beforeCreate
parent created
child beforeCreate
child created
child2 beforeCreate
child2 created
child mounted
child2 mounted
parent mounted
### 简单的基于 `vuejs` 的 `eventbus`
1. 在main.js文件加入
`Vue.prototype.$eventHub = new Vue()`
2. 在监听页面加入
`this.$eventHub.$on('fire', function (data) {});`
3. 在发送页面加入
`this.$eventHub.$emit('fire','data');`
4. 记得取消监听,会消耗性能
`this.$eventHub.$off('fire');`
## 编辑器
#### Visual Studio设置同步
使用Setting Sync 插件管理。里面的code或Id用文件记住。
## 移动端
### 常用css
```css
user-select: none; // 禁止文字被选中
outline:none; // 去除点击外边框,点击无轮廓
-webkit-touch-callout: none; // 长按链接不弹出菜单
-webkit-tap-highlight-color: rgba(0,0,0,0); // 去除点击高亮
@media only screen and (min-width: 320px) {
html {
font-size: 13.65px;
}
}
@media only screen and (min-width: 360px) {
html {
font-size: 15.36px;
}
}
@media only screen and (min-width: 375px) {
html {
font-size: 16px;
}
}
@media only screen and (min-width: 390px) {
html {
font-size: 16.64px;
}
}
@media only screen and (min-width: 414px) {
html {
font-size: 17.664px;
}
}
@media screen and (min-width: 640px) {
html {
font-size: 27.31px;
}
}
html {
font-size: 4.266667vw;
}
@px: 16rem;