Vue Code Snippet
重置 data 的数据为初始状态 this.$data = { ...this.$data, ...this.$options.data() }; // Object.assign(this.$data, this.$options.data()); Object.assign({}, this.$options.data().form, { type: 1 }); 修改 ElementUI 默认样式 vue 中令人头疼的 element-ui 组件默认 css 样式修改 | juejin <template> <div class="my-class"> <el-table> </el-table> </div> </template> <style lang="scss" scoped> .my-class__expand-column .cell { display: none; } .my-class .el-table tbody tr:hover > td { cursor: pointer; } </style> watch 对象的属性 data: { a: 100, msg: { channel: "音乐", style: "活泼" } }, watch: { a(newval, oldVal) { console.log("new: %s, old: %s", newval, oldVal); } } watch: { msg: { handler(newValue, oldValue) { console.log(newValue) }, // 深度监听 deep: true } } 监听对象内的某一具体属性,可以通过 computed 做中间层来实现: computed: { channel() { return this.msg.channel } }, watch:{ channel(newValue, oldValue) { console.log('new: %s, old: %s', newValue, oldValue) } } 判断 data 中的对象是否为空 1、利用 jQuery 的 isEmptyObject: ...