2018-11-1工作日報
阿新 • • 發佈:2018-11-05
1.在es6的學習中遇到了兩種宣告函式的方式:
js中關於function兩種宣告的區別——預解析
//函式表示式,和變數宣告同等
var a=function(){
alert(10)
}
//函式宣告,優於變數宣告
function a(){
alert(10)
}
2.繼續昨天的ES6教程學習,import 和 export,import匯入模組、export匯出模組
//全部匯入 import people from './example' //有一種特殊情況,即允許你將整個模組當作單一物件進行匯入 //該模組的所有匯出都會作為物件的屬性存在 import * as example from "./example.js" console.log(example.name) console.log(example.age) console.log(example.getName()) //匯入部分 import {name, age} from './example' // 匯出預設, 有且只有一個預設 export default App // 部分匯出 export class App extend Component {};
以前有人問我,匯入的時候有沒有大括號的區別是什麼。下面是我在工作中的總結:
1.當用export default people匯出時,就用 import people 匯入(不帶大括號) 2.一個檔案裡,有且只能有一個export default。但可以有多個export。 3.當用export name 時,就用import { name }匯入(記得帶上大括號) 4.當一個檔案裡,既有一個export default people, 又有多個export name 或者 export age時,匯入就用 import people, { name, age } 5.當一個檔案裡出現n多個 export 匯出很多模組,匯入時除了一個一個匯入,也可以用import * as example
3.在複習以前寫的部落格規範時,發現自己並沒有遵循圖示儘量不使用img標籤的規範,於是找何時使用img標籤,何時使用background-image背景影象
4、順帶複習es6和之前的this指向的研究,this 指向詳細解析(箭頭函式)
6.學習慕課網vue課程,並自己寫了點demo:
其中watch方法是監聽Num值的變化,當發生改變是,呼叫方法,值得注意的是,我這全採用的es6的函式寫法,省略了function
data(){ return { hhhs:'233333', num:1 } }, methods:{ getNum(){ this.num++; } }, watch:{ 'num'(val,oldVal){ console.log(val,oldVal) } }