The vue parent component updates the value passed by it, but the child component receives no update value.

Just add the watch listening time to the subcomponent

// 子组件
export default {
    props: {
	    type: {
		    type: String,
	    	default: '',
	    },
    },
    data(){
        return{
            datatype :''
        }
    },
    watch: {
        // 更新属性type
	    type: {
			handler(newVal, oldVal) {
				console.log(newVal, oldVal)
				if (newVal !== oldVal) {
					this.datatype = newVal;

					// 再次重新请求数据接口即可
				}
			},
			immediate: true,
			deep: true,
		},
    },
}

Supongo que te gusta

Origin blog.csdn.net/qq_40047019/article/details/132244705
Recomendado
Clasificación