Vue.js 我怎么能在合成api中观看道具?
更新道具时如何调用函数 父容器:Vue.js 我怎么能在合成api中观看道具?,vue.js,vue-props,Vue.js,Vue Props,更新道具时如何调用函数 父容器: <div> <Maintable :type="typeRef" :country="countryRef" /> </div> export default{ props: ['type'], setup(props) { watch(props.type, () => {
<div>
<Maintable :type="typeRef" :country="countryRef" />
</div>
export default{
props: ['type'],
setup(props)
{
watch(props.type, () => {
console.log('hello')
})
}
此代码获取错误:无效的监视源。。。
如何收听道具的更新
希望有人能帮助我!!:-) 尝试将prop from函数作为第一个参数返回:
export default{
props: ['type'],
setup(props)
{
watch(()=>props.type, (newVal) => {
console.log('hello')
})
}
谢谢你的回答,但我很抱歉,我不明白你的意思:)不客气,我的意思是不要看
watch(props.type,
dowatch(()=>props.type,
,因为()=>props.type
是一个返回道具的箭头函数,它是观察者属性的参数。我仍然会收到相同的错误…请检查此问题的解决方案