const isShow = reffalseconst BigImgField = reffunction openBigImgField string BigImgFieldvalue = Field isShowvalue = reftrue consolelogBigImgFieldvalue这段代码有什么问题
这段代码没有明显的语法错误,但是存在以下问题:
-
isShow.value = ref(true)中不应该再次使用ref,因为isShow已经是一个响应式对象了,应该直接赋值为true。 -
在
console.log(BigImgField.value)中,BigImgField已经是一个响应式对象了,不需要再使用.value来获取其值。
正确的代码应该是:
const isShow = ref(false)
const BigImgField = ref()
function openBigImg(Field: string) {
BigImgField.value = Field
isShow.value = true
console.log(BigImgField)
}
原文地址: https://www.cveoy.top/t/topic/bYWL 著作权归作者所有。请勿转载和采集!