Skip to content

Commit 065b0f6

Browse files
committed
版本升级,添加showBtns属性,完善文本
1 parent 59639e7 commit 065b0f6

File tree

6 files changed

+48
-15
lines changed

6 files changed

+48
-15
lines changed

README.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ A jsoneditor of vue.js
55
vue.js
66

77
## 组件属性
8-
v-model:必须,组件的json对象
8+
v-model:必须,[json对象]组件的json对象
9+
:showBtns: boolean,是否显示保存按钮,默认为true
10+
@json-change: json发生变化后的事件
911

1012
# 怎么使用
1113
## 1. 使用npm安装vue-json-editor
@@ -18,7 +20,7 @@ npm install vue-json-editor --save
1820
<div>
1921
<p>vue-json-editor使用</p>
2022
<!--在模板中使用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
2224
<div>
2325
</template>
2426
@@ -35,6 +37,12 @@ npm install vue-json-editor --save
3537
// 注入vueJsonEditor组件
3638
components: {
3739
vueJsonEditor
40+
},
41+
42+
methods: {
43+
onJsonChange (value) {
44+
console.log('value:', value)
45+
}
3846
}
3947
}
4048
</script>

example/App.vue

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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>

example/main.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import Vue from 'vue'
2-
import vueJsonEditor from '../vue-json-editor.vue'
2+
import App from './App.vue'
33

44
new Vue({
55
el: '#app',
6-
components: { vueJsonEditor },
6+
components: { App },
77
render (h) {
8-
return h('vueJsonEditor')
8+
return h('App')
99
}
1010
})

package.json

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-json-editor",
3-
"version": "1.0.3",
3+
"version": "1.1.0",
44
"description": "A json editor of vue",
55
"main": "vue-json-editor.vue",
66
"scripts": {
@@ -13,14 +13,13 @@
1313
"url": "git+https://github.com/dirkliu/vue-json-editor.git"
1414
},
1515
"keywords": [
16+
"vue-json-editor",
17+
"vuejsoneditor"
18+
"json-editor",
19+
"jsoneditor",
1620
"json",
1721
"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"
2423
],
2524
"author": "liuqi41",
2625
"license": "ISC",

vue-json-editor.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div>
33
<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>
55
</div>
66
</template>
77

@@ -10,7 +10,7 @@
1010
import JsonEditor from './assets/jsoneditor'
1111
1212
export default {
13-
props: ['value'],
13+
props: ['value', 'showBtns'],
1414
data () {
1515
return {
1616
editor: null,

webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module.exports = {
3939

4040
devServer: {
4141
contentBase: path.join(__dirname),
42-
port: 80,
42+
port: 8080,
4343
open: true,
4444
inline: true
4545
}

0 commit comments

Comments
 (0)