Content-Length: 372848 | pFad | http://github.com/weizhenye/vue-highcharts/commit/ab216d3f363b419e6800ffcf9cde2678bd2dfb1c

99 use template for Vue 1.x (#5) · weizhenye/vue-highcharts@ab216d3 · GitHub
Skip to content

Commit ab216d3

Browse files
committed
use template for Vue 1.x (#5)
1 parent dfa83b1 commit ab216d3

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

src/create.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
import clone from './clone.js';
22
import ctors from './constrators.js';
33

4-
function create(tagName, Highcharts) {
4+
function create(tagName, Highcharts, Vue) {
55
var Ctor = Highcharts[ctors[tagName]];
66
if (!Ctor) {
77
return null;
88
}
99
var isRenderer = tagName === 'highcharts-renderer';
10-
return {
10+
var component = {
1111
name: tagName,
12-
render: function(createElement) {
13-
return createElement('div');
14-
},
1512
props: isRenderer
1613
? {
1714
width: { type: Number, required: true },
@@ -37,9 +34,6 @@ function create(tagName, Highcharts) {
3734
}
3835
}
3936
},
40-
mounted: function() {
41-
this._initChart();
42-
},
4337
beforeDestroy: function() {
4438
if (isRenderer) {
4539
this.$el.removeChild(this.renderer.box);
@@ -50,12 +44,24 @@ function create(tagName, Highcharts) {
5044
} else {
5145
this.chart.destroy();
5246
}
53-
},
54-
// compat Vue v1.x
55-
ready: function() {
56-
this._initChart();
5747
}
5848
};
49+
var isVue1 = /^1\./.test(Vue.version);
50+
if (isVue1) {
51+
component.template = '<div></div>';
52+
component.ready = function() {
53+
this._initChart();
54+
};
55+
} else {
56+
component.render = function(createElement) {
57+
return createElement('div');
58+
};
59+
component.mounted = function() {
60+
this._initChart();
61+
};
62+
}
63+
return component;
5964
}
6065

6166
export default create;
67+

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function install(Vue, options) {
66
var Highcharts = (options && options.Highcharts) || HighchartsOnly;
77
Vue.prototype.Highcharts = Highcharts;
88
for (var tagName in ctors) {
9-
var component = create(tagName, Highcharts);
9+
var component = create(tagName, Highcharts, Vue);
1010
component && Vue.component(tagName, component);
1111
}
1212
}

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/weizhenye/vue-highcharts/commit/ab216d3f363b419e6800ffcf9cde2678bd2dfb1c

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy