// 请求方法列表 Vue.component("http-methods-box", { props: ["v-methods"], data: function () { let methods = this.vMethods if (methods == null) { methods = [] } return { methods: methods, isAdding: false, addingMethod: "" } }, methods: { add: function () { this.isAdding = true let that = this setTimeout(function () { that.$refs.addingMethod.focus() }, 100) }, confirm: function () { let that = this // 删除其中的空格 this.addingMethod = this.addingMethod.replace(/\s/g, "").toUpperCase() if (this.addingMethod.length == 0) { teaweb.warn("请输入要添加的请求方法", function () { that.$refs.addingMethod.focus() }) return } // 是否已经存在 if (this.methods.$contains(this.addingMethod)) { teaweb.warn("此请求方法已经存在,无需重复添加", function () { that.$refs.addingMethod.focus() }) return } this.methods.push(this.addingMethod) this.cancel() }, remove: function (index) { this.methods.$remove(index) }, cancel: function () { this.isAdding = false this.addingMethod = "" } }, template: `
` })