我正在尝试 vue 中的 语法,并想知道为什么反应性不起作用。这里出了什么问题?
<template>
<button @click="changeButtonText">{{ buttonText }}</button>
</template>
<script setup>
import { ref } from 'vue'
let buttonText = ref("Foo")
function changeButtonText() {
buttonText = "Bar"
}
</script>
尝试不使用 ref()。
尝试使用 buttonText = ref("Bar")。没有效果
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号