在knockoutJS中,可以订阅视图模型属性的更改,例如:
myViewModel.personName.subscribe(function(newValue) {
alert("The person's new name is " + newValue);
});
我目前正在学习AngularJS,我想知道在AngularJS中是否有类似的东西?我试着搜索这个,但没有任何运气。
我有一个关于useRef的问题:如果我将ref.current添加到useEffect的依赖项列表中,并且当我更改了ref.current的值时,useEffect内部的回调就不会被触发。
例如:
export default function App() {
const myRef = useRef(1);
useEffect(() => {
console.log("myRef current changed"); // this only gets triggered when the component mounts
}, [myRef.cur