Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions practice/xny/--课后学习笔记--.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# **课后学习笔记**

标签(空格分隔): web React

---

###### 文章一 http://www.infoq.com/cn/articles/subversion-front-end-ui-development-framework-react
###### 心得: 感觉React把搭建网页变成搭积木,搭建好了之后也不用修改整个积木堆,只要对具体的某个积木进行操作,讲道理就是更高效更偷懒了

###### 文章二 http://www.infoq.com/cn/articles/react-art-of-simplity
###### 心得:
1.取消自动绑定
2.代码容易理解
3.将HTML直接嵌入到JavaScript代码中
4.通过虚拟DOM让框架自身去解决哪些局部UI需要更新的问题
5.单向数据流动:Flux
6.使用只读数据来建立数据模型
###### 文章三 http://reactjs.cn/react/docs/thinking-in-react.html
###### 心得: prop预设 不可变 state状态 反复变(不准确的说法。。。)
----------
**问题:**
我找了一个例子 主要是两个人读了他的代码,基本知道了怎么写
https://github.com/YikaJ/react-todos
1. 代码里 bundle.js 这里面的代码是手写的还是生成的?
2. localdb 这个本地数据库 了解和使用
3.
```html
todoCount: this.state.todos.length || 0,
todoDoneCount: (this.state.todos && this.state.todos.filter((todo)=>todo.isDone)).length || 0
```
####这里的逻辑判断是什么意思?
----------
######**Tips(提醒我自己。。。):http://www.cnblogs.com/vajoy/p/4591274.html 最后讲了怎么实现onclick 可以用来实现TODO中勾选完成事项**

7 changes: 7 additions & 0 deletions practice/xny/1/Thinking liujiawang.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#前端学习课程1感想
##感觉这并不是老师你要求的那个markdown 所以我觉得我加的这些##号看起来和智障一样。
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

确实啊。不是发了一个学习 md 链接吗,, http://www.jianshu.com/p/q81RER

以及标准写法,# 啊,# 后面应该有个空格

###其实报班之前挺忐忑的,无悬念9个人中基础最差的我,也是赶鸭子上架,可能先学一下css html js打好基础再来学习会更好,可是又觉得这样的机会挺难得的,没法错过,所以硬着头皮来听课
###第一节课听紧张的,看那些东西都是一脸懵逼,要是再被提问还不会,那特么就比较尴尬了
###不过大神们讲的很细很慢,思维还能跟得上,没出现那种一言不合就开快车的情况,听欣慰了
###关于这次作业的话。。。清明出去玩了四天。。。作业也是压着deadline。。。全靠队友carry,我还在看他的代码。。。
####最后还是感谢大神们提供这么好的学习机会,希望下次的感想我扯得是些关于代码的问题。。。康桑米达。。。
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加油

3 changes: 3 additions & 0 deletions practice/xny/1/Thinking xieninyu.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
深复制和浅复制的一点疑问,深复制是对对象的所有属性进行遍历直到出现出现基本类型再直接复制过来,然后基本类型是储存在栈中,
对于对象,栈中储存的是对象名和地址,然后储存的内容是存放在堆中,当进行深复制时,通过栈中储存的地址进入到堆中,遍历所有
属性然后直到出现基本属性,那是不是深复制后的都是储存在栈中..堆中储存的是像树那样的子类和父类的关系么。。。
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

深复制后的都是储存在栈中,

错,比如 a = {...},b={},b深复制 a,之后 a、b 变量名(其实就是地址)在栈中,但是会有两个{...}在堆中,

像树那样的子类和父类的关系,

说法有问题,不是类,,是父节点和子节点,其实你可以把对象理解成树的,它其实是一种混合的数据结构,不限制深度的特殊字典(key 即属性名,并且 key 只能为 str),理解成树是没问题的,只不过子节点对于父节点是有名字的(属性名 str)

ps:问问题,要简练,明确。把知道和不知道的写在一起,会影响解答者理解。。。。提问是一个很有用很重要的技术活,加油

14 changes: 14 additions & 0 deletions practice/xny/1/answer1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var str1 = "123"
var answer1 = parseInt(str1)
console.log(str1)
console.log(answer1);










9 changes: 9 additions & 0 deletions practice/xny/1/answer2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Created by Khalil on 2016/4/4.
*/
var array = ['1','2','1','3','4']
var answer2 = array.map(function (num) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以直接var answer2 = array.map(Number)

return Number(num)
})
console.log(array);
console.log(answer2);
7 changes: 7 additions & 0 deletions practice/xny/1/answer3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Created by Khalil on 2016/4/4.
*/

//var childCollection = document.querySelectorAll('div');
//TODO:将集合转化为真正的数组
//var childs = Array.call(childCollection)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

错了,请看答案,预习 prototype 知识

9 changes: 9 additions & 0 deletions practice/xny/1/answer4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Created by Khalil on 2016/4/4.
*/
function spacify(str) {
var newStr = str.replace(/ /,'').split('');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice,很棒的将复杂问题简单化了,正则以后有兴趣和需求的时候可以系统学一学

return newStr.join(' ')
}
var answer4 = spacify('hello world')
console.log(answer4);
8 changes: 8 additions & 0 deletions practice/xny/1/answer5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Created by Khalil on 2016/4/4.
*/
function Convension(str) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

函数名应该小写,,

var tmp = str.split('').sort()
return tmp.join('')
}
console.log(Convension('dsadafafasfdg'))
12 changes: 12 additions & 0 deletions practice/xny/1/answer6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Created by Khalil on 2016/4/4.
*/
function Logbytime(arr) {
var a = ['a', 'b', 'c', 'd']
for(var i = 0; i < a.length;i++)
{
(function(j){setTimeout(function(){console.log(a[j]);}, j * 1000);})(i);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

答案是对的,但是只有一行。。。。请改改,不要写成一行

//var t = setTimeout(function(){console.log(a[i]);}, 1000);
}
}
var answer6 = Logbytime();
7 changes: 7 additions & 0 deletions practice/xny/1/answer7.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Created by Khalil on 2016/4/4.
*/

function log() {
console.log.apply(console, arguments)
}
15 changes: 15 additions & 0 deletions practice/xny/1/answer8.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Created by Khalil on 2016/4/4.
*/
var User = {
count:1,

getCount:function() {
return this.count;
}
};

console.log(User.getCount());// 1

var func = User.getCount();
console.log(func());//报错 func is not a function this这里指向的是func不是user 所以func中没有count
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

答对80%,不是报错,是 undefined, 因为 this 还是有指向的,指向全局对象。

7 changes: 7 additions & 0 deletions practice/xny/1/try.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Created by Khalil on 2016/4/4.
*/
var array = ['1','2','1','3','4']
var answer2 = array.map(Number)
console.log(array);
console.log(answer2);
2 changes: 2 additions & 0 deletions practice/xny/2/Xieninyu.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
����Ͽθ�������ľ��DZ�̷������� ������������ʵ��һֱ������ ������һ��һֱ��̫���� ����ʹ��Enter���е�ʱ�� ��ʱ����Զ���ǰ��ճ���������
��ʱ���򲻻� ��Ҫ�ֶ������� ��Ȼֻ�Ǹ�Сϸ�� ������д�����ʱ����������ͦ���ĵ� ���Ų����
23 changes: 23 additions & 0 deletions practice/xny/2/code2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="cn">
<head>
<meta charset="UTF-8">
<title>Web homework 2</title>
<style>
ul {
list-style-type:none;
text-align:left;
}
input{
align-self: center;
}
input:-ms-input-placeholder{text-align: center;}
input::-webkit-input-placeholder{text-align: center;}
</style>
</head>
<body style="text-align: center">
<br /><img src="https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png" width="400" height="200" /><br />
<input type="search" placeholder="search" id="search" size="120" style="height: 40px" >
</body>
<script src="tee.js"></script>
</html>
99 changes: 99 additions & 0 deletions practice/xny/2/tee.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/**
* Created by Khalil on 2016/4/6.
*/
var input=document.getElementById('search');
var data=[
{
key:'alibaba',
value:'阿里巴巴'
},
{
key:'baidu',
value:'百度'
},
{
key:'sexi',
value:'色系'
},
{
key:'sejie',
value:'色戒'
},
{
key:'sina',
value:'sina'
},
{
key:'secai',
value:'色彩'
},
{
key:'sennv',
value:'森女'
},
{
key:'secaixinggeceshi',
value:'色彩性格测试'
},
{
key:'seo',
value:'seo'
},
{
key:'sem',
value:'sem'
},
{
key:'22cunxianshiqi',
value:'22寸显示器'
},
{
key:'22cunlaganxiang',
value:'22寸拉杆箱'
},
{
key:'zhizhang',
value:'智障'
},
];
var result=[];
var msg=document.createElement('div');
msg.id="msg";
input.parentNode.appendChild(msg);

input.onfocus=function(event){

result=[];
msg.innerHTML='';
auto();
};
input.onkeyup=auto;
input.onblur=function(event){
if(msg){
document.body.removeChild(msg);
}
};
function auto(event){
var reg=new RegExp('^'+input.value);
var i;
result=[];
msg.innerHTML='';
if(input.value===''){
msg.innerHTML='';
return;
}
if(msg){
for(i=0;i<data.length;i++){
if(reg.test(data[i].key)){
result.push(data[i].value);
}
}
}
var ul=document.createElement('ul');
msg.appendChild(ul);
for(i=0;i<result.length;i++){
var li=document.createElement('li');
li.innerHTML=result[i];
ul.appendChild(li);
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码还行,就是代码风格有待加强,适当的多换行,函数与函数之间,可以隔一行,= 两边要空格。

对 DOM 有兴趣的话可以看看上次作业的标准答案
https://github.com/SimplyY/web-front-end-thinking-tutorial/blob/master/practice/yuwei/2/index.js

有了 react 不需要任何 DOM操作,兼容性 ok,react 大法好。

17 changes: 17 additions & 0 deletions practice/xny/2/thinking2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# thinking2

前端学习心得

---

#####突然开窍知道怎么用Markdown了233333
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

但也不是这么用 orz,标题才用#,正文不需要加符号。

#####刚开始看到这个题目一脸懵逼,后来打开网页看看 居然开到了别人的代码【捂脸】
#####都是靠查W3C
#####后来根据百度的办法 把JS代码嵌入到head里无反应,找同学帮忙调试了一个多小时
#####还是靠问大神光速解决 【掩面哭泣】
#####还在翻JS入门经典的书。。。只能边上课边学基础知识。。