Skip to content

Commit 40f5942

Browse files
author
Pooya Parsa
committed
Fix problems with playground and export
1 parent 7082769 commit 40f5942

File tree

1 file changed

+13
-22
lines changed

1 file changed

+13
-22
lines changed

docs/pages/play.vue

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,16 @@
123123
`;
124124
125125
const exampleJS = `
126-
{
127-
data: {
128-
progress: Math.random() * 100
129-
},
130-
methods: {
131-
clicked() {
132-
this.progress = Math.round(Math.random()*10000)/100;
133-
console.log("Change progress to " + this.progress);
134-
}
126+
data: {
127+
progress: Math.random() * 100
128+
},
129+
methods: {
130+
clicked() {
131+
this.progress = Math.round(Math.random()*10000)/100;
132+
console.log("Change progress to " + this.progress);
135133
}
136-
}`;
134+
}
135+
`;
137136
138137
export default {
139138
components: {layout},
@@ -178,17 +177,14 @@
178177
179178
console.warn = function (text) {
180179
self.log('warning', text);
181-
self.originalWarn.apply(console, arguments);
182180
};
183181
184182
console.log = function (text) {
185183
self.log('info', text);
186-
self.originalLog.apply(console, arguments);
187184
};
188185
189186
console.error = function (text) {
190187
self.log('danger', text);
191-
self.originalError.apply(console, arguments);
192188
};
193189
}
194190
},
@@ -210,16 +206,11 @@
210206
];
211207
},
212208
js_fiddle() {
213-
// Inject options
214-
let js = this.js.trim();
215-
js = `{el:'#app',\r\n` + js.substring(1);
216-
return `new Vue(${js})`.trim();
209+
let js = `new Vue({el:'#app',\r\n${this.js.trim()}})`.trim();
210+
return `window.onload = function() {${js}}`;
217211
},
218212
html_fiddle() {
219-
return `
220-
<div id='app'>
221-
${this.html}
222-
</div>`.trim();
213+
return `<div id='app'>\r\n${this.html}\r\n</div>`.trim();
223214
},
224215
lazy_run() {
225216
if (!this.lazy_run_) {
@@ -280,7 +271,7 @@
280271
let options;
281272
try {
282273
/* eslint-disable no-eval */
283-
eval('options=' + this.js);
274+
eval('options={' + this.js + '}');
284275
} catch (err) {
285276
throw new Error(`Compiling JS: ${err}`);
286277
}

0 commit comments

Comments
 (0)