<template>
<h2>名字: {{ name }}</h2>
<h2>年龄: {{ age }}</h2>
<button @click="changeName">修改名字</button>
<button @click="changeAge">修改年龄</button>
<button @click="showTel">查看联系方式</button>
</template>
<script lang="ts">
export default {
name: 'Person',
setup() {
let name = 'lc'
let age = 22
let tel = '123456'
function changeAge() {
name = 'hackerdvd'
}
function changeAge() {
age += 1
}
function showTel() {
alert(tel)
}
return {name, age, tel, changeAge, changeName, showTel}
}
}
</script>
Uncaught ReferenceError: changeName is not defined
setup Person.vue:25
callWithErrorHandling runtime-core.esm-bundler.js:195
setupStatefulComponent runtime-core.esm-bundler.js:7630
setupComponent runtime-core.esm-bundler.js:7591
mountComponent runtime-core.esm-bundler.js:5917
processComponent runtime-core.esm-bundler.js:5883
patch runtime-core.esm-bundler.js:5351
componentUpdateFn runtime-core.esm-bundler.js:6027
run reactivity.esm-bundler.js:177
update runtime-core.esm-bundler.js:6151
setupRenderEffect runtime-core.esm-bundler.js:6161
mountComponent runtime-core.esm-bundler.js:5929
processComponent runtime-core.esm-bundler.js:5883
patch runtime-core.esm-bundler.js:5351
render2 runtime-core.esm-bundler.js:6672
mount runtime-core.esm-bundler.js:3938
mount runtime-dom.esm-bundler.js:1535
<anonymous> main.ts:4
Person.vue:25:41
setup Person.vue:25
callWithErrorHandling runtime-core.esm-bundler.js:195
setupStatefulComponent runtime-core.esm-bundler.js:7630
setupComponent runtime-core.esm-bundler.js:7591
mountComponent runtime-core.esm-bundler.js:5917
processComponent runtime-core.esm-bundler.js:5883
patch runtime-core.esm-bundler.js:5351
componentUpdateFn runtime-core.esm-bundler.js:6027
run reactivity.esm-bundler.js:177
update runtime-core.esm-bundler.js:6151
setupRenderEffect runtime-core.esm-bundler.js:6161
mountComponent runtime-core.esm-bundler.js:5929
processComponent runtime-core.esm-bundler.js:5883
patch runtime-core.esm-bundler.js:5351
render2 runtime-core.esm-bundler.js:6672
mount runtime-core.esm-bundler.js:3938
mount runtime-dom.esm-bundler.js:1535
<anonymous> main.ts:4
标签:tmp,core,name,bundler,js,esm,runtime
From: https://www.cnblogs.com/hacker-dvd/p/18173221