-
一、課程介紹
1、運(yùn)用(jquery? - ES3、VUE - ES6、React - ES6)
2、涉及內(nèi)容(常量、作用域、箭頭函數(shù)、默認(rèn)參數(shù)、對(duì)象代理)
查看全部 -
es5中的function函數(shù)中this指的是“誰(shuí)調(diào)用的這個(gè)方法,這個(gè)方法的this就指向誰(shuí)”;
es6中箭頭函數(shù)中的this指向的是:“誰(shuí)定義了這個(gè)方法,這個(gè)方法的this就指向誰(shuí)”
查看全部 -
eslint查看全部
-
var,let作用域
立即執(zhí)行函數(shù)和花括號(hào)的作用域
查看全部 -
... 擴(kuò)展運(yùn)算符
查看全部 -
安裝GIt執(zhí)行操作
查看全部 -
ES6原生語(yǔ)法代理 : let ?object = new Proxy() ; ?object 為 用戶訪問(wèn)操作的代理對(duì)象,而不是原始對(duì)象 //ES6? ?let Person = { ?//創(chuàng)建一對(duì)象 ? ? name: 'es6', ? ? sex: 'male', ? ? age: 15 ? }; ? let person = new Proxy(Person, { ?//Person為代理的對(duì)象 ? ? get(target, key) { ? //get為讀取操作,參數(shù)target為代理對(duì)象的數(shù)據(jù),key是你要讀的哪個(gè)屬性。 ? ? ? return target[key] ? ? }, ? ? set(target,key,value){ //set為設(shè)置修改操作,value為屬性值 ? ? ? if(key!=='sex'){ ? ? ? ? target[key]=value; ? ? ? } ? ? } ? });查看全部
-
什么是對(duì)象代理?比如我們封裝了一組數(shù)據(jù),通過(guò)訪問(wèn)代理,對(duì)數(shù)據(jù)訪問(wèn)做限制,而用戶訪問(wèn)的是代理層,而不是源數(shù)據(jù)。這樣就數(shù)據(jù)進(jìn)行保護(hù)。查看全部
-
es3采用閉包的形式去保護(hù)數(shù)組,而es5直接采用defineProperty的方式去保護(hù)數(shù)組查看全部
-
// es5 { var Person = { name : 'es5', age : 15 }; Object.defineProperty(Person,'sex',{ writable : false, value : 'male' }); //讀取 console.table({name : person.name,sex : person.sex,age : person.age}); person.name = 'es5-cname'; console.table({name : person.name,sex : person.sex,age : person.age}); // 報(bào)錯(cuò) person.sex = 'female'; console.table({name : person.name,sex : person.sex,age : person.age}); } ? // es6 { ?let Person = { ? name : 'es6', ? sex : 'male', ? age : 18 ?}; ? ?let person = new Proxy(Person,{ get(target,key){ return target[key]; }, set(target,key,value){ if(key != 'sex') target[key] = value; } ?}); ? ?// 讀取 ?console.table({name : person.name,sex : person.sex,age : person.age}); ? ?// 修改 ?try{ person.sex = 'female'; ?}catch(e){ console.log(e); ?}finally{ ?}? }查看全部
-
// 數(shù)據(jù)保護(hù) // es3 { ?var Person = function(){ // 局部作用域 var data = { name : 'es3', sex : 'male', age : 15 } this.get = function (key){ return data[key]; } this.set = function(key, value){ if(key != 'sex'){ data[key] = value; } } ?} ? ?var person = new Person(); ? ?//讀取 ?console.table({name : person.get('name'),sex : person.get('sex'),age : person.get('age')}); ? ?// 修改 ?person.set('name','es3-cname'); ?console.table({name : person.get('name'),sex : person.get('sex'),age : person.get('age')}); ? ?person.set('sex','female'); ?console.table({name : person.get('name'),sex : person.get('sex'),age : person.get('age')}); ? }查看全部
-
//es5?
Object.defineProperty(window,'name',{
????value:? 'test',
????writable: false
})
查看全部 -
常量、作用域、箭頭函數(shù)、默認(rèn)參數(shù)、對(duì)象代理
查看全部 -
//ES5 中的常量,設(shè)置常量是只讀的 ? Object.defineProperty(window,"pi1",{ ? ?value:3.141592, ? ?writable:false,//不可編輯 }) console.log("pi1:"+pi1); ? // ES6 中的常量 不能賦值? const pi2=3.1415926 console.log("pi2:"+pi2); ? //pi2=4 ? 加上這句會(huì)報(bào) pi2 是只讀的錯(cuò)誤查看全部
-
一、基礎(chǔ) Git, Webpack,? JS 二、ES6環(huán)境搭建步驟 1. 安裝git? 2. 下載webpack es6項(xiàng)目到本地:git clone? https://github.com/cucygh/es6-webpack.git (在cmd輸入,??上萩d到指定目錄)?? 3. cd到根目錄: cd?es6-webpack? (在cmd輸入)?? 4. 安裝webpack:npm/cnpm install?(在cmd輸入)? 5. 全局安裝:npm/cnpm install webpack -g(在cmd輸入)? 6. 全局安裝:npm/cnpm install webpack-dev-server -g(在cmd輸入)? 7. 運(yùn)行項(xiàng)目:npm/cnpm start(在cmd輸入)? 三、webpack構(gòu)建環(huán)境 1. 自動(dòng)編譯ES6語(yǔ)法? 2. 改動(dòng)代碼并且保存,瀏覽器會(huì)自動(dòng)刷新?? 四、前端學(xué)習(xí)筆記 下載到本地: git clone https://github.com/cucygh/fe-material.git查看全部
舉報(bào)
0/150
提交
取消