这段代码没有明显的语法错误,但是存在以下问题:

  1. isShow.value = ref(true) 中不应该再次使用 ref,因为 isShow 已经是一个响应式对象了,应该直接赋值为 true

  2. 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)
}
const isShow = reffalseconst BigImgField = reffunction openBigImgField string BigImgFieldvalue = Field isShowvalue = reftrue consolelogBigImgFieldvalue这段代码有什么问题

原文地址: https://www.cveoy.top/t/topic/bYWL 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录