const fetchData = async () => {
try {
const response = await fetch('https://api.example.com/data');
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
data.value = await response.json();
} catch (err) {
error.value = `An error occurred: ${err.message}`;
}
};
computed、watch和watchEffect区别computed: 计算属性将基于它们的响应依赖关系缓存,本质上是为了简化模版中的逻辑 支持set方法: 模版引用两次,但是只会执行一次运算,只有当firstName和sec...