Vue computed calculation attribute when the dependent property is updated, the calculation property is not executed?

computed: {
    comp: function () {
        return () => import(`./component/item${this.formItem.item_type}.form`);
    }
},

when I switch the value of this.formItem.item_type, comp is not triggered

computed: {
    comp: function () {
        console.log(this.formItem.item_type)
        return () => import(`./component/item${this.formItem.item_type}.form`);
    }
},

when I add console.log (this.formItem.item_type), it triggers normally, but comment out doesn"t trigger normally. Why?

in addition: I use watch to monitor normal

watch:{
    "formItem.item_type": function (val, oldVal) {
        this.comp = () => import(`./component/item${this.formItem.item_type}.form`);
    }
},

supplement this.formItem objects

clipboard.png

Mar.23,2021

first check whether this.formItem.item_type is responsive. Expand to this point with the developer tool, if it is (.) or if there is a light-colored get/set below, otherwise, this variable is not observed, so there is no response.


because only if you access the corresponding variable in the evaluation property, the calculation property can form a dependence on it.

comp: function () {
    // ,  comp 
    this.formItem.item_type;
  
    return () => import(`./component/item${this.formItem.item_type}.form`);
}
Menu