1.
selectFilter(key,option){ this.search.filter.key=option; this.$forceUpdate(); }
vuv在这样给map赋值时候(this.search.filter.key=option; )会默认把key当做字符串,不认为他是个变量等于this.search.filter["key"]=option;
解决:this.search.filter[key]=option; 使用中括号
2.
selectFilter(key,option){ // this.search.filter[key]=option; //watch监听不到对象内部对象的改变 // 解决方法: // 1.拷贝对象 const {... obj}=this.search.filter //2.给拷贝对象赋值 obj.filter[key]=option; // 3.将拷贝的对象赋值给原来对象 this.search().filter=obj; this.$forceUpdate(); }
乐优商城的坑,这里要改未true