使用組合式api時資料改變了但頁面上的值沒有改變,狀態沒有重繪
解決方案:使用 ref 官方檔案:https://v3.cn.vuejs.org/api/refs-api.html#ref
javascript:
setup(){
const status = ref("");
return{
status
}
}
typescript:
setup(){
const status:Ref<string> = ref("");
return{
status
}
}
頁面:
<div>{{ status }}</div>
你要是看不懂,就可以暫時粗暴的理解成,凡事要在頁面上用的資料,就要用ref(當然還有別的方式)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/300359.html
標籤:其他
