1<script>
2export default {
3 mounted() {
4 this.myMethod()
5 },
6 methods:{
7 myMethod() {
8 let _this = this
9 let self = this
10 let that = this
11 window.addEventListener('click', function() {
12 console.log('this scope (function) >', this)
13 console.log('this scope (vuejs) >', _this)
14 console.log('this scope (vuejs) >', self)
15 console.log('this scope (vuejs) >', that)
16 })
17 }
18 }
19}
20</script>
21
1<script>
2export default {
3 data:() => ({
4 myData: 1
5 }),
6 mounted() {
7 this.myMethod()
8 },
9 methods:{
10 myMethod() {
11 window.addEventListener('click', () => {
12 console.log('this >', this.myData)
13 })
14 }
15 }
16}
17</script>
18