需求: 每過1秒顯示隱藏教育
"test"
>
@click
="destoryvm"
>
destory vmbutton
>
v-show
="isshow"
>
教育p>
div>
new
vue(
,mounted()
,1000)}
})
錯誤原因:這裡setinterval
呼叫匿名函式後導致this傳送改變,變成了window
new
vue(
,mounted()
,1000)}
, methods:},
beforedestroy()
})
new
vue(
,mounted()
,1000)}
})
匿名函式使用箭頭函式來是用,這種寫法是不會有自己的this,所以會呼叫外部的this也就是vm 箭頭函式及箭頭函式中this的使用
1.定義函式的方式 function const aaa function 3.es6中的箭頭函式 const ccc 引數列表 3.1 有乙個引數 括號可省略 const sum num1 3.2 有兩個引數 const sum num1,num2 3.3 函式 塊中有多行 時 依次寫 const...
箭頭箭頭函式
var fn function a 一樣 jineng function 箭頭函式外面指向誰就指向誰 有function.console.log fn3 1 像函式表示式 this指向不變.不能作為建構函式 不能使用new 返回物件的話.外部用括號 var fn7 name asdfnasd age...
箭頭函式寫法 箭頭函式
1 箭頭函式介紹 es6 let fn v v console.log fn 好酷的箭頭函式!好酷的箭頭函式!es5 let fn function v 和return省略掉 v v v 相當於 function v 和return v 和return時,如果返回的內容是乙個物件,物件需要用括號 括...