V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
V2EX  ›  zythum  ›  全部回复第 13 页 / 共 153 页
回复总数  3049
1 ... 9  10  11  12  13  14  15  16  17  18 ... 153  
2015 年 11 月 23 日
回复了 nlimpid 创建的主题 Markdown 如何让某个页面只打开一次?
window.open(url, name, opts)
name: 可以些一个字符串。那么相同字符串的就不会打开新页面了。
2015 年 11 月 23 日
回复了 qianyu77 创建的主题 问与答 如果程序员都去大学当老师,会是什么样?
大学老师学历要求可高呢。野生程序员木有那么高学历..
2015 年 11 月 23 日
回复了 xujunfu 创建的主题 职场话题 没工作
去哪不搬砖。不着急。像朱一当时就着急了...
2015 年 11 月 20 日
回复了 XDA 创建的主题 分享发现 IT 从业者一部 iPhone 4 用了 5 年是什么情况?
- -, 朱一也用的 iPhone4.... 掩面路过... @Lanzi 我要换手机。被嘲讽了 55555
2015 年 11 月 20 日
回复了 exoticknight 创建的主题 JavaScript ES6 箭头函数的问题
给他赋个名字不就解决了....
2015 年 11 月 20 日
回复了 kenshinhu 创建的主题 React React 中如何使用第三方类库
@kenshinhu 如果你是用第三方代码。不是 vdom 的。就要不要用 react 内部的方式去更新 dom 。因为会导致第三方操作 dom 的时候 dom 被 react 删掉导致悲剧。

其实 https://facebook.github.io/react/docs/component-specs.html 文档还是挺清楚的。但是都在边边角角些的。如果你要知道内部逻辑就只能看源码了。
但是基本就是下面的逻辑(如果说的不对。大大纠正)。

createElement -> componentWillMount -> render -> 生成 html -> innerHTML 填充 -> componentDidMount

props 变更 -> componentWillReceiveProps -> shouldComponentUpdate -> render -> diff(内部) -> change dom

setState -> shouldComponentUpdate -> render -> diff(内部) -> change dom

forceUpdate -> render -> diff(内部) -> change dom
2015 年 11 月 20 日
回复了 kenshinhu 创建的主题 React React 中如何使用第三方类库
react 内部其实 调 render 只有 初始化的时候、调用 setState 的时候、外面更新 props 或者直接调用 forceUpdate 。调用 render 方法会返回目前的 vdom ,然后 react 比较现在和之前的 vdom 的差异,然后更新 dom 。

调用 setState 的时候、外面更新 props 时会通过 shouldComponentUpdate, componentWillReceiveProps componentWillReceiveProps 的方法给你中间介入的手段 ...
2015 年 11 月 20 日
回复了 kenshinhu 创建的主题 React React 中如何使用第三方类库
@kenshinhu 你可以试试。反正折腾么... 233333
2015 年 11 月 20 日
回复了 kenshinhu 创建的主题 React React 中如何使用第三方类库
撸个伪代码大概这样

React.createClass({
getDefaultProps: function() {
return {
onSelectedStyleStateChange: function () {},
contentText: ''
};
},
componentDidMount: function () {
this.states.editor = new RichEditor( React.findDOMNode(this) );
this.states.editor.on('select', onSelectedStyleStateChange);
this.states.editor.addContent(this.props.contentText);
},
componentWillUnmount: function() {
this.states.editor.destroy();
},
componentWillUpdate: function () {
return false;
},
componentWillUpdate: function() {
this.componentWillUnmount();
},
componentDidUpdate: function() {
this.componentDidMount();
},
render: function () {
return <div className="editview"></div>
}
});
2015 年 11 月 20 日
回复了 kenshinhu 创建的主题 React React 中如何使用第三方类库
我大概清楚了。你想在一个模块内使用第三方的代码。第三方的代码是强 dom 控制的,没发使用 react 的 vdom 。那么就是需要自己写一个 reactClass 来封装一下。在这个 class 做特殊生命周期处理做适配。

首先 componentDidMount 和 componentWillUnmount 做这个第三方代码的 初始化 和 析构 工作,当然 html 还是写在 render 里面。
然后把 shouldComponentUpdate 直接 return false, 使得改变 props 和 states 时不会自行更新 dom 。但是一旦这么设置你就不能监听 props 和 states 改变了。所以需要自行在 componentWillUpdate 和 componentDidUpdate 里面实现。

但是 shouldComponentUpdate 并不能拦住全部,文档说了, This method is not called for the initial render or when forceUpdate is used. 所以以防万一谁 forceUpdate ,所以认为一旦 update 就直接这个模块析构再初始化
componentWillUpdate: function() { this.componentWillUnmount(); }
componentDidUpdate: function() { this.componentDidMount(); }

不知道你能不能看懂, 朱一的语文不是很好。但是应该能看懂吧....

总结就是。这个模块不能通过 react 内部逻辑去改变 dom 。所以把所有手段都劫持调,自己实现。
2015 年 11 月 9 日
回复了 iheshix 创建的主题 分享发现 微博药丸!微博把默认主题改成双 11 了。
不久给爹一个面子么。有什么好大惊小怪的。有没碍着你使用功能呢。也没给你在信息流里面插秋裤链接。只是给爹一个面子都不行啊。
就好比,老板说: 我给你发件文化衫。你给我个面子,穿一星期咋样。
@beordle 朱一不做页面构建...
2015 年 11 月 6 日
回复了 Delbert 创建的主题 分享发现 收到一条短信,求调教
2015 年 11 月 6 日
回复了 ibireme 创建的主题 iDev 发布 iOS 富文本组件: YYText
先码
瞧不起朱一啊。不知道朱一色盲啊...5555555
很好奇。多少钱?
先聊 5 毛钱的....
@muziling 关于浏览器兼容问题 你要兼容 ie67 这仨都不行。
2015 年 11 月 3 日
回复了 amlionone 创建的主题 新手求助 sublime 配置标签问题
请 google: snippet sublime
@flyingkid 真的,我 mm 南孚聚能环能用 2 月。
1 ... 9  10  11  12  13  14  15  16  17  18 ... 153  
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4459 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 33ms · UTC 09:54 · PVG 17:54 · LAX 02:54 · JFK 05:54
♥ Do have faith in what you're doing.