2019-10-31
先不说【捕捉,冒泡】是什么东西(概念)
首先我们来看一段代码12345678910// html<div id="grand"> 爷爷 <div id="father"> 爸爸 <div id="son"> 儿子 </div&...
Read More
2019-10-18
首先创建一个全局变量文件 global.scss1$theme-color: #efefef;
编辑 vue.config.js1234567891011module.exports = { // ... css: { loaderOptions: { sass: { // 根据自己样...
Read More
2019-10-15
1234567891011121314151617$red-color: #6f0; // 变量.userCard { width: 100px; &.active { // &符号 background: yellow; } &-name { color: black; ...
Read More
2019-08-23
今天在做订单中心的时候,ios端出现如下时间错误。
终发现原来 new Date() 在 安卓 和 ios 上的不同表现
当我们用JavaScript实例化一个日期对象时,我们可以这样用:
1let date = new Date();
上面这段代码是获取当前日期,这段代码在 Firefox、Chrome、Safari 浏览器中都可以运行。但是如果我想根...
Read More
2019-07-02
传统的css方案css in html直接在 html 里面写 css 或者用 link 引入
像这个样子
12345678910111213141516<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>CSS...
Read More
2019-07-01
先来看React v16.3之前的生命周期函数(图中实际上少了componentDidCatch),如下图。
constructor
componentWillMount
render
componentDidMount
componentShouldUpdate
componentWillUpdate
render
componentDidUpdate...
Read More
2019-06-25
2019/6/24
Find The Parity Outlier
[2, 4, 0, 100, 4, 11, 2602, 36]Should return: 11 (the only odd number)
[160, 3, 1719, 19, 11, 13, -21]Should return: 160 (the only eve...
Read More
2019-06-23
假设我们现在遇到如下场景:
1234567891011121314151617function fn1(){ fn2()}function fn2(){ fn3()}function fn3(){ fn4()}function fn4(){ console.log(...) // ...
Read More
2019-06-23
上文我们已经用自己的 eventHub 来完成了任意组件之间的通讯,接下来我们使用 redux 来达到相同的功能。直接看官网的例子,我们直接开始改写这样
可以看到思路和我们的 eventHub 差不多,只不过 redux 使用了更多新名词(吐槽…)订阅事件用 subscribe , 触发事件用 dispatch,触发事件的名字用 type ,传递的参数为...
Read More
2019-06-23
1. 任意两个组件之间如何通信
2. 发布订阅模式
3. Redux 就那么回事
上篇文章说到了组件传值可以通过 props 来传值,
但是当我们遇到嵌套组件很深的时候或者任意组件通讯的时候,
比如说这个时候
当我们点击 minus 的时候只有当前组件的数据在变化,但是我们希望这个数据在变化的时候通知其他组件同时变化,所以,如果继续用 props ...
Read More