fix: 🐛 修复弹窗switch开关显示问题

This commit is contained in:
albert
2022-07-11 15:03:52 +08:00
parent 5856faaef3
commit 401aaf97a4
8 changed files with 109 additions and 7 deletions

View File

@@ -11,11 +11,15 @@
[![MIT License](https://img.shields.io/github/license/zyqwst/json-schema-editor-vue.svg)](https://github.com/zyqwst/json-schema-editor-vue/blob/master/LICENSE) [![MIT License](https://img.shields.io/github/license/zyqwst/json-schema-editor-vue.svg)](https://github.com/zyqwst/json-schema-editor-vue/blob/master/LICENSE)
A json-schema editor of high efficient and easy-to-use, base on Vue A json-schema editor of high efficient and easy-to-use, base on Vue
### [json-schema-editor of Vue3](https://github.com/zyqwst/-json-schema-editor-vue3)
<p align="center"> <p align="center">
<img width="100%" src="https://github.com/zyqwst/json-schema-editor-vue/raw/master/examples/assets/capture.png"> <img width="100%" src="https://github.com/zyqwst/json-schema-editor-vue/raw/master/examples/assets/capture.png">
</p> </p>
**支持自定义属性,满足特殊的需求** **支持自定义属性,满足特殊的需求*
<p align="center"> <p align="center">
<img width="100%" src="https://github.com/zyqwst/json-schema-editor-vue/raw/master/examples/assets/custom.png"> <img width="100%" src="https://github.com/zyqwst/json-schema-editor-vue/raw/master/examples/assets/custom.png">
</p> </p>
@@ -27,7 +31,12 @@ A json-schema editor of high efficient and easy-to-use, base on Vue
### Usage ### Usage
```bash ```bash
```bash
# vue2
npm install json-schema-editor-vue npm install json-schema-editor-vue
# vue3
npm install json-schema-editor-vue3
```
``` ```
```vue ```vue

1
dist/css/chunk-vendors.8b9389a0.css vendored Normal file

File diff suppressed because one or more lines are too long

24
dist/js/chunk-vendors.9c1262ef.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/js/index.c28e0210.js vendored Normal file

File diff suppressed because one or more lines are too long

53
dist/report.html vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{ {
"name": "json-schema-editor-vue", "name": "json-schema-editor-vue",
"version": "2.0.2", "version": "2.0.3",
"author": "zhangyq", "author": "zhangyq",
"description": "A json-schema editor of high efficient and easy-to-use, base on Vue", "description": "A json-schema editor of high efficient and easy-to-use, base on Vue",
"keywords": [ "keywords": [

View File

@@ -66,7 +66,7 @@
<span v-else-if="advancedAttr[key].type === 'boolean'" style="display:inline-block;width:100%"> <span v-else-if="advancedAttr[key].type === 'boolean'" style="display:inline-block;width:100%">
<a-switch v-model="advancedValue[key]"/> <a-switch v-model="advancedValue[key]"/>
</span> </span>
<a-textarea @blur="changeEnumValue" :value="advancedValue['enum'] && advancedValue['enum'].length && advancedValue['enum'].join('\n')" :rows="2" v-else-if="key === 'enum'" :placeholder="local['enum_msg']"></a-textarea> <a-textarea @blur="changeEnumValue" :value="enumText" :rows="2" v-else-if="key === 'enum'" :placeholder="local['enum_msg']"></a-textarea>
<a-select v-else-if="advancedAttr[key].type === 'array'" v-model="advancedValue[key]" style="width:100%" :getPopupContainer=" <a-select v-else-if="advancedAttr[key].type === 'array'" v-model="advancedValue[key]" style="width:100%" :getPopupContainer="
triggerNode => { triggerNode => {
return triggerNode.parentNode || document.body; return triggerNode.parentNode || document.body;
@@ -210,6 +210,12 @@ export default {
t[item.key] = item.value t[item.key] = item.value
} }
return Object.assign({},this.pickValue,this.advancedNotEmptyValue, t) return Object.assign({},this.pickValue,this.advancedNotEmptyValue, t)
},
enumText () {
const t = this.advancedValue['enum']
if (!t) return ''
if (!t.length) return ''
return t.join('\n')
} }
}, },
data(){ data(){
@@ -280,8 +286,16 @@ export default {
const pickType = this.pickValue.type const pickType = this.pickValue.type
const value = e.target.value const value = e.target.value
var arr = value.split('\n') var arr = value.split('\n')
if (arr.length === 0) return
this.advancedValue.enum = arr.map(item => pickType === 'string' ? item : +item) if (pickType === 'string') {
this.advancedValue.enum = arr.map(item => item);
} else {
if(arr.length ===0 || (arr.length === 1 && arr[0]=='')) {
this.advancedValue.enum = null
}else {
this.advancedValue.enum = arr.map(item => +item);
}
}
}, },
_deepCheck(checked,node){ _deepCheck(checked,node){
if(node.type === 'object' && node.properties){ if(node.type === 'object' && node.properties){

View File

@@ -15,9 +15,9 @@ export function copyAttr(source, target){
export function isNull(ele){ export function isNull(ele){
if(typeof ele==='undefined'){ if(typeof ele==='undefined'){
return true; return true;
}else if(ele==null){ }else if(ele===null){
return true; return true;
}else if(ele==''){ }else if(ele===''){
return true; return true;
} }
return false; return false;