Vue.component("http-request-conds-view", { props: ["v-conds"], data: function () { let conds = this.vConds if (conds == null) { conds = { isOn: true, connector: "or", groups: [] } } let that = this conds.groups.forEach(function (group) { group.conds.forEach(function (cond) { cond.typeName = that.typeName(cond) }) }) return { initConds: conds, version: 0 // 为了让组件能及时更新加入此变量 } }, computed: { // 之所以使用computed,是因为需要动态更新 conds: function () { return this.initConds } }, methods: { typeName: function (cond) { let c = window.REQUEST_COND_COMPONENTS.$find(function (k, v) { return v.type == cond.type }) if (c != null) { return c.name; } return cond.param + " " + cond.operator }, notifyChange: function () { this.version++ let that = this this.initConds.groups.forEach(function (group) { group.conds.forEach(function (cond) { cond.typeName = that.typeName(cond) }) }) } }, template: `
{{version}}
{{cond.param}} {{cond.operator}} {{cond.typeName}}: {{cond.value}} {{group.connector}}  
` })