实用方法
1.img:[ {url:require('../../../../assets/index/passimg.svg')}, {url:require('../../../../assets/index/passerror.svg')}, ], 使用时: <div v-show="status==1"> <img :src="img[0].url" alt=""> </div> <div v-show="status==2"> <img :src="img[1].url" alt=""> </div>
![](https://img2020.cnblogs.com/blog/1999448/202006/1999448-20200629092701502-1717293865.png)
2.v-htmlv-html所要表达的是未被转义过的内容,所以<h1></h1>,以及<p>标签没有显示出来。 <div> <div v-html="noteData.contents"> </div>
3.跳转传参 this.$router.push({path:path,query:{status:'' ,views:JSON.stringify(row)}})
4.vue中给input框赋值,无法修改的问题 <input type="text" v-model="form.name"> methods:{ //请求数据 goodsList(id){ this.$request(this.$config.baseApi+'/user/address/index?uid='${id},'get') .then(res=>{ if (res.code===200){ //如果用这种方式直接赋值,很可能会在页面上不能编辑,所以让它强制刷新 //根据官方文档定义:如果在实例创建之后添加新的属性到实例上,它不会触发视图更新 // this.form.name=res.data.content //解决办法:$set this.$set(this.form,'name',this.form.name) } }) } }
5. // js根据对象数组中的时间来排序 sortKey(array, key) { return array.sort(function(a, b) { var x = a[key]; var y = b[key]; return x > y ? -1 : x < y ? 1 : 0; }); }, //使用 this.tableData1=this.sortKey(this.tableData1, "checkTime")