代码之家  ›  专栏  ›  技术社区  ›  DarkFenix

为什么我第二次使用vue时进程不起作用?

  •  0
  • DarkFenix  · 技术社区  · 8 年前

    我有一个小的Vue应用程序,它有一个包含更多组件的父组件,最初我从数据库中获取一些产品数据,这些数据是通过Vue计算的数组中存储的。

    我能做错什么?,在第一次结束时,我所做的是按照以下方式重置data(){}元素的值。

     this.showModalOptions= false;
     this.showModalType= false;
     this.udpdateprecios = false;
     this.products=[];
     this.productsselect= [];
     this.productselect={};
     this.type= {};
     this.obtenerProducts(); //get productos y assign to array products
    

    所得产品法

     obtenerProducts(){
            axios.get('/api/products/all')
            .then((result) => {
                this.products= result.data.productos;
    
            });
        },
    

    声明数据()

    data() {
            return {
                products: [],
                productselect: {},
                type: {},
                productsselect: [], 
                showModalOptions: false,
                showModalType: false,
    
            };
        },
    

    我不能添加一个对我有用的例子,也许这不是重置数组或对象的方法,它们停止反应?

    1 回复  |  直到 8 年前
        1
  •  0
  •   Jerry    8 年前

    如果如你所说,属性改变,屏幕保持不变,也许你应该试试 vm.$forceUpdate() vm.$nextTick(yourFunction) 刷新事件队列。