map方法写在外面可以正常,写在function报错
function num() {
const c = this.data.map(item => {
return item * 2
})
console.log(c)
}
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'map')
at num (index.html:31:47)
at Proxy.mounted (index.html:37:17)
at vue3.2.45.js:4279:44
at callWithErrorHandling (vue3.2.45.js:1744:26)
at callWithAsyncErrorHandling (vue3.2.45.js:1753:25)
at Array.hook.__weh.hook.__weh (vue3.2.45.js:4253:33)
at flushPostFlushCbs (vue3.2.45.js:1925:51)
at render (vue3.2.45.js:7752:13)
at mount (vue3.2.45.js:5983:29)
at Object.app.mount (vue3.2.45.js:10924:27)