File tree 6 files changed +48
-15
lines changed
6 files changed +48
-15
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,9 @@ A jsoneditor of vue.js
5
5
vue.js
6
6
7
7
## 组件属性
8
- v-model:必须,组件的json对象
8
+ v-model:必须,[ json对象] 组件的json对象
9
+ :showBtns: boolean,是否显示保存按钮,默认为true
10
+ @json-change : json发生变化后的事件
9
11
10
12
# 怎么使用
11
13
## 1. 使用npm安装vue-json-editor
@@ -18,7 +20,7 @@ npm install vue-json-editor --save
18
20
<div>
19
21
<p>vue-json-editor使用</p>
20
22
<!--在模板中使用vue-json-editor-->
21
- <vue-json-editor v-model="json"></vue-json-editor
23
+ <vue-json-editor v-model="json" :showBtns="true" @json-change="onJsonChange" ></vue-json-editor
22
24
<div>
23
25
</template>
24
26
@@ -35,6 +37,12 @@ npm install vue-json-editor --save
35
37
// 注入vueJsonEditor组件
36
38
components: {
37
39
vueJsonEditor
40
+ },
41
+
42
+ methods: {
43
+ onJsonChange (value) {
44
+ console.log('value:', value)
45
+ }
38
46
}
39
47
}
40
48
</script>
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <vue-json-editor v-model =" json" :showBtns =" false" @json-change =" onJsonChange" ></vue-json-editor >
3
+ </template >
4
+
5
+ <script >
6
+ import vueJsonEditor from ' ../vue-json-editor.vue'
7
+ export default {
8
+ data () {
9
+ return {
10
+ json: {
11
+ name: " Dirk"
12
+ }
13
+ }
14
+ },
15
+
16
+ components: {
17
+ vueJsonEditor
18
+ },
19
+
20
+ methods: {
21
+ onJsonChange (value ) {
22
+ console .log (' value:' , value);
23
+ }
24
+ }
25
+ }
26
+ </script >
Original file line number Diff line number Diff line change 1
1
import Vue from 'vue'
2
- import vueJsonEditor from '../vue-json-editor .vue'
2
+ import App from './App .vue'
3
3
4
4
new Vue ( {
5
5
el : '#app' ,
6
- components : { vueJsonEditor } ,
6
+ components : { App } ,
7
7
render ( h ) {
8
- return h ( 'vueJsonEditor ' )
8
+ return h ( 'App ' )
9
9
}
10
10
} )
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " vue-json-editor" ,
3
- "version" : " 1.0.3 " ,
3
+ "version" : " 1.1.0 " ,
4
4
"description" : " A json editor of vue" ,
5
5
"main" : " vue-json-editor.vue" ,
6
6
"scripts" : {
13
13
"url" : " git+https://github.com/dirkliu/vue-json-editor.git"
14
14
},
15
15
"keywords" : [
16
+ " vue-json-editor" ,
17
+ " vuejsoneditor"
18
+ " json-editor" ,
19
+ " jsoneditor" ,
16
20
" json" ,
17
21
" eidtor" ,
18
- " jsoneditor\u001b [D\u001b [D\u001b [D\u001b [D\u001b [D\u001b [D\u001b [D\u001b [D\u001b [D\u001b [D\u001b [D" ,
19
- " \u001b [B\u001b [B\u001b [B\u001b [A\u001b [A\u001b [A\u001b [C\u001b [C\u001b [C\u001b [C\u001b [C\u001b [C\u001b [C\u001b [C\u001b [C\u001b [C" ,
20
- " json-editor" ,
21
- " vue-json-editor" ,
22
- " vue" ,
23
- " jsoneditor"
22
+ " vue"
24
23
],
25
24
"author" : " liuqi41" ,
26
25
"license" : " ISC" ,
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div >
3
3
<div class =" jsoneditor-vue" ></div >
4
- <div class =" jsoneditor-btns" ><button class =" json-save-btn" type =" button" @click =" onSave()" :disabled =" error" >保存</button ></div >
4
+ <div class =" jsoneditor-btns" v-if = " showBtns!==false " ><button class =" json-save-btn" type =" button" @click =" onSave()" :disabled =" error" >保存</button ></div >
5
5
</div >
6
6
</template >
7
7
10
10
import JsonEditor from ' ./assets/jsoneditor'
11
11
12
12
export default {
13
- props: [' value' ],
13
+ props: [' value' , ' showBtns ' ],
14
14
data () {
15
15
return {
16
16
editor: null ,
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ module.exports = {
39
39
40
40
devServer : {
41
41
contentBase : path . join ( __dirname ) ,
42
- port : 80 ,
42
+ port : 8080 ,
43
43
open : true ,
44
44
inline : true
45
45
}
You can’t perform that action at this time.
0 commit comments