Skip to content

Commit

Permalink
fix value change and height not resize
Browse files Browse the repository at this point in the history
  • Loading branch information
陈峰 committed Mar 25, 2019
1 parent e4d6af2 commit 8a9721d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
10 changes: 7 additions & 3 deletions example/build/webpack.dev.conf.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
const path = require('path');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
mode: 'development',
entry: './example/app.js',
output: {
path: path.join(__dirname, '../dist'),
filename: 'main.js'
},
devtool: 'cheap-module-source-map',
devServer: {
port: 8081
port: 8081,
disableHostCheck: true
},
resolve: {
extensions: ['.js', '.vue'],
Expand All @@ -26,8 +29,8 @@ module.exports = {
exclude: /node_modules/
},
{
test: /\.css$/,
use: ['vue-style-loader', 'css-loader', 'autoprefixer-loader']
test: /\.s?css$/,
use: ['vue-style-loader', 'css-loader', 'sass-loader']
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
Expand Down Expand Up @@ -59,5 +62,6 @@ module.exports = {
template: './example/index.html',
inject: true
}),
new VueLoaderPlugin(),
]
}
6 changes: 6 additions & 0 deletions lib/json-viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ export default {
expandCode: false
}
},
watch: {
value() {
this.onResized()
}
},
computed: {
jvClass () {
return 'jv-container ' + this.theme + (this.boxed ? ' boxed' : '')
Expand All @@ -96,6 +101,7 @@ export default {
methods: {
onResized () {
this.$nextTick(() => {
console.log(this.$refs.jsonBox.$el.clientHeight)
if (this.$refs.jsonBox.$el.clientHeight >= 250) {
this.expandableCode = true
} else {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-json-viewer",
"version": "2.1.0",
"version": "2.1.1",
"description": "vuejs展示json的组件",
"main": "dist/vue-json-viewer.js",
"files": [
Expand Down

0 comments on commit 8a9721d

Please sign in to comment.